-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
25 lines (25 loc) · 932 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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { createServer } = require('https')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { parse } = require('url')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const next = require('next')
// eslint-disable-next-line @typescript-eslint/no-var-requires
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(5678, (err) => {
if (err) throw err
// eslint-disable-next-line no-console
console.log('> Server started on https://localhost:5678')
})
})