-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8911ae5
commit 458e6f0
Showing
5 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { createServer } = require('https'); | ||
const mkcert = require('mkcert'); | ||
const fs = require('fs'); | ||
const { parse } = require('url'); | ||
const path = require('path'); | ||
const next = require('next'); | ||
|
||
const currentPort = parseInt(process.env.PORT, 10) || 3000 | ||
const hostname = process.env.HOSTNAME || '0.0.0.0' | ||
|
||
const app = next({ | ||
dev: false, | ||
hostname, | ||
port: currentPort, | ||
}); | ||
|
||
const httpsOptions = { | ||
key: fs.readFileSync(path.join(__dirname, 'certificates/localhost-key.pem')), | ||
cert: fs.readFileSync(path.join(__dirname, 'certificates/localhost.pem')), | ||
} | ||
|
||
const handle = app.getRequestHandler(); | ||
app.prepare().then(async () => { | ||
createServer(httpsOptions, async (req, res) => { | ||
const parsedUrl = parse(req.url, true); | ||
handle(req, res, parsedUrl); | ||
}).listen(currentPort, async () => { | ||
console.log(`> Ready on https://${hostname}:${currentPort}`); | ||
}); | ||
}); |