-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (23 loc) · 738 Bytes
/
server.js
File metadata and controls
25 lines (23 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const { createServer } = require("https");
const { parse } = require("url");
const { readFileSync } = require("fs");
const next = require("next");
const port = 3000;
const app = next({ dev: true, hostname: "0.0.0.0", port });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer(
{
key: readFileSync("./localhost-key.pem"),
cert: readFileSync("./localhost.pem"),
},
(req, res) => {
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
}
).listen(port, "0.0.0.0", (err) => {
if (err) throw err;
console.log(`Ready on https://localhost:${port}`);
console.log(`Also accessible on your network at https://<your-local-ip>:${port}`);
});
});