You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
650 B
20 lines
650 B
3 years ago
|
const { createServer } = require("https");
|
||
|
const { parse } = require("url");
|
||
|
const next = require("next");
|
||
|
const fs = require("fs");
|
||
|
const dev = process.env.NODE_ENV !== "production";
|
||
|
const app = next({ dev });
|
||
|
const handle = app.getRequestHandler();
|
||
|
const httpsOptions = {
|
||
|
key: fs.readFileSync("./certs/localhost.key"),
|
||
|
cert: fs.readFileSync("./certs/localhost.crt"),
|
||
|
};
|
||
|
app.prepare().then(() => {
|
||
|
createServer(httpsOptions, (req, res) => {
|
||
|
const parsedUrl = parse(req.url, true);
|
||
|
handle(req, res, parsedUrl);
|
||
|
}).listen(3000, (err) => {
|
||
|
if (err) throw err;
|
||
|
console.log("> Server started on https://localhost:3000");
|
||
|
});
|
||
|
});
|