forked from cofacts/rumors-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
25 lines (21 loc) · 745 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
// Copies from production `next start` script
// https://github.com/zeit/next.js/blob/canary/packages/next/cli/next-start.ts
// https://github.com/zeit/next.js/blob/canary/packages/next/server/lib/start-server.ts
//
const { createServer } = require('http');
const next = require('next');
const { resolve } = require('path');
const port = parseInt(process.env.PORT, 10) || 3000;
const app = next({ dir: resolve('.') });
const srv = createServer(app.getRequestHandler());
srv.on('listening', () => {
app.prepare().then(() => {
// eslint-disable-next-line no-console
console.log(`> Ready on http://localhost:${port}`);
});
});
srv.on('error', err => {
console.error('Startup error', err);
process.exit(1);
});
srv.listen(port);