-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (29 loc) · 859 Bytes
/
server.js
File metadata and controls
32 lines (29 loc) · 859 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
26
27
28
29
30
31
32
const { createServer } = require("https");
const { parse } = require("url");
const { readFileSync } = require("fs");
const next = require("next");
const port = 3000;
const dev = process.env.NODE_ENV !== "production";
const app = next({ dev });
const handle = app.getRequestHandler();
var httpsOptions;
if (dev) {
httpsOptions = {
key: readFileSync("./localhost-key.pem"),
cert: readFileSync("./localhost.pem"),
};
} else {
httpsOptions = {
key: readFileSync("/etc/ssl/certs/__eri_ucsb_edu.key"),
cert: readFileSync("/etc/ssl/certs/__eri_ucsb_edu_cert.cer"),
};
}
app.prepare().then(() => {
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}`);
});
});