-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (26 loc) · 814 Bytes
/
server.js
File metadata and controls
30 lines (26 loc) · 814 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
const https = require('https');
const { parse } = require('url');
const next = require('next');
const fs = require('fs');
const dev = process.env.NODE_ENV !== 'production';
const PORT = 3000;
const hostname = 'localhost'; // or 커스텀 도매인
const app = next({ dev, hostname, PORT });
const handle = app.getRequestHandler();
const key = fs.readFileSync(`${__dirname}/localhost-key.pem`, 'utf8');
const cert = fs.readFileSync(`${__dirname}/localhost.pem`, 'utf8');
const httpsOptions = {
key,
cert,
};
app.prepare().then(() => {
https
.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://${hostname}:${PORT}`);
});
});