2018-10-20 14:58:21 +00:00
|
|
|
// This file doesn't go through babel or webpack transformation.
|
|
|
|
// Make sure the syntax and sources this file requires are compatible with the current node version you are running
|
|
|
|
// See https://github.com/zeit/next.js/issues/1245 for discussions on Universal Webpack or universal Babel
|
|
|
|
const { createServer } = require('http')
|
|
|
|
const { parse } = require('url')
|
|
|
|
const next = require('next')
|
|
|
|
|
|
|
|
const dev = process.env.NODE_ENV !== 'production'
|
|
|
|
const app = next({ dev })
|
|
|
|
const handle = app.getRequestHandler()
|
|
|
|
|
|
|
|
app.prepare().then(() => {
|
|
|
|
let server = createServer((req, res) => {
|
|
|
|
// Be sure to pass `true` as the second argument to `url.parse`.
|
|
|
|
// This tells it to parse the query portion of the URL.
|
|
|
|
const parsedUrl = parse(req.url, true)
|
|
|
|
handle(req, res, parsedUrl)
|
2018-10-20 17:37:42 +00:00
|
|
|
}).listen(process.env.PORT, process.env.IP || '0.0.0.0', err => {
|
2018-10-20 14:58:21 +00:00
|
|
|
if (err) throw err
|
2018-10-20 17:37:42 +00:00
|
|
|
let addr = server.address()
|
|
|
|
console.log('> Ready on http://', addr.address + ':' + addr.port)
|
2018-10-20 14:58:21 +00:00
|
|
|
})
|
2018-10-20 17:37:42 +00:00
|
|
|
})
|