mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
3ece48b603
* Add test for /_next/development route * Make sure useFileSystemPublicRoute: false only disables filesystem routing * Bring back comment * Add useFileSystemPublicRoutes tests
34 lines
827 B
JavaScript
34 lines
827 B
JavaScript
const micro = require('micro')
|
|
const next = require('next')
|
|
|
|
const dev = process.env.NODE_ENV !== 'production'
|
|
const dir = __dirname
|
|
const port = process.env.PORT || 3000
|
|
|
|
const app = next({ dev, dir })
|
|
const handleNextRequests = app.getRequestHandler()
|
|
|
|
app.prepare().then(() => {
|
|
const server = micro((req, res) => {
|
|
if (/setAssetPrefix/.test(req.url)) {
|
|
app.setAssetPrefix(`http://127.0.0.1:${port}`)
|
|
} else if (/setEmptyAssetPrefix/.test(req.url)) {
|
|
app.setAssetPrefix(null)
|
|
} else {
|
|
// This is to support multi-zones support in localhost
|
|
// and may be in staging deployments
|
|
app.setAssetPrefix('')
|
|
}
|
|
|
|
handleNextRequests(req, res)
|
|
})
|
|
|
|
server.listen(port, (err) => {
|
|
if (err) {
|
|
throw err
|
|
}
|
|
|
|
console.log(`> Ready on http://localhost:${port}`)
|
|
})
|
|
})
|