-
Notifications
You must be signed in to change notification settings - Fork 4
error with create-next-app #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The error message is different on Next v13.5.4
|
I have the same error message on next v13.5.5 |
in my case, i'm running a simple custom server for https based on below links. vercel/next.js#10935 in fact, next-dev-https presumably works the same way, but I can't figure out why it doesn't work in my case. anyway, my scripts are like this server_dev.js:
package.json:
|
Hey, sorry for neglecting this package. It turns out NextJS server API seems to be quite the moving target, that requires frequent tuning with NextJS releases. The combination of limited time in life, not currently working with NextJS and the fact that this solution is incompatible with Turbopack has made me decided to not continue supporting this package. Meanwhile NextJS has implemented experimental support for https in the official package, i would recommend trying that solution over this package. vercel/next.js#10935 (comment) If running into issues when NextJS updates i could also recommend just keeping a server around like @brownie11636 suggest. This package can be used a template: https://github.com/TobiasMelen/next-dev-https/blob/main/src/server.js Is anyone currently having urgent issues in their project because of this package not working with latest NextJS versions? Will keep the issue around for a couple of days. |
Thank you @brownie11636 @TobiasMelen. I've had some problems with Anyone who doesn't want to deal with certificates, here is what I ended up with, also copying certificate generation part. Need to install const { createServer } = require('https');
const { parse } = require('url');
const next = require('next');
const fs = require('fs');
const path = require('path');
const { X509Certificate } = require('crypto');
const selfSigned = require('selfsigned');
const hostname = 'localhost';
const port = 4430;
const generateCertificate = () => {
const certDir = path.join(__dirname, 'certificates');
if (!fs.existsSync(certDir)) {
fs.mkdirSync(certDir, { recursive: true });
}
const certPath = path.join(certDir, 'cert-sha256.pem');
const keyPath = path.join(certDir, 'key-sha256.pem');
const existingCert = fs.existsSync(certPath) && fs.readFileSync(certPath, { encoding: 'utf-8' });
const existingKey = fs.existsSync(keyPath) && fs.readFileSync(keyPath, { encoding: 'utf-8' });
if (existingCert && existingKey && new Date(new X509Certificate(existingCert).validTo) > new Date()) {
return { cert: existingCert, key: existingKey };
}
const selfSignedCert = selfSigned.generate(undefined, {
algorithm: 'sha256',
keySize: 2048,
});
fs.writeFileSync(certPath, selfSignedCert.cert);
fs.writeFileSync(keyPath, selfSignedCert.private);
return { cert: selfSignedCert.cert, key: selfSignedCert.private };
};
const app = next({ dev: true, hostname, port });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer(generateCertificate(), async (req, res) => {
try {
const parsedUrl = parse(req.url ?? '', true);
await handle(req, res, parsedUrl);
} catch (err) {
console.error('Error occurred handling', req.url, err);
res.statusCode = 500;
res.end('internal server error');
}
}).listen(port, () => {
console.log(`Ready on https://${hostname}:${port}`);
});
}); |
I was using this app really well until one day it started to not work in my project with a message
Error: Invariant getCompilationError called outside render worker
.To find the problem, I installed this package on create-next-app and tried to run it, but I got the same error.
The strange thing is that it seems to work well in the sandbox of this repository.
what should i do to use it with create-next-app?
How to reproduce:
full error message:
The text was updated successfully, but these errors were encountered: