forked from joshzcold/Friendly-Feud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
27 lines (25 loc) · 776 Bytes
/
server.js
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
26
27
const { parse } = require("url");
const next = require("next");
const dev = process.env.NODE_ENV !== "production";
const app = next({ dev });
const fs = require("fs");
const handle = app.getRequestHandler();
let httpsOptions = {};
var { createServer } = require("http");
if (dev) {
var { createServer } = require("https");
httpsOptions = {
key: fs.readFileSync("./dev/cert/localhost.key"),
cert: fs.readFileSync("./dev/cert/localhost.crt"),
};
}
const PORT = process.env.PORT || 3000;
app.prepare().then(async () => {
createServer(httpsOptions, (req, res) => {
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
}).listen(PORT, (err) => {
if (err) throw err;
console.log(`> Ready on https://localhost:${PORT}`);
});
});