const next = require('next'); const https = require('https'); const fs = require('fs'); const dev = process.env.NODE_ENV !== 'production'; const app = next({ dev }); const handle = app.getRequestHandler(); app.prepare().then(() => { https.createServer({ key: fs.readFileSync('./localhost-key.pem'), cert: fs.readFileSync('./localhost.pem'), }, (req, res) => { handle(req, res); }).listen(3000, (err) => { if (err) throw err; console.log('> Ready on https://localhost:3000'); }); });