-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (28 loc) · 867 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
26
27
28
29
30
require('dotenv').config({});
const express = require('express');
const nextjs = require('next');
const http = require('http');
const dev = process.env.NODE_ENV !== 'production';
const app = nextjs({ dev });
const handle = app.getRequestHandler();
app
.prepare()
.then(() => {
const server = express();
server.get('/', (req, res) => {
const actualPage = '/index';
return app.render(req, res, actualPage);
});
server.get('*', (req, res) => handle(req, res));
const httpsServer = http.createServer(server);
httpsServer.listen(process.env.PORT, (err) => {
if (err) throw err;
// eslint-disable-next-line no-console
console.log(`> Ready on http://localhost:${process.env.PORT}`);
});
})
.catch((ex) => {
// eslint-disable-next-line no-console
console.error(ex.stack);
process.exit(1);
});