rsnext/test/integration/basepath/server.js
JJ Kasper dd6a08980a
Normalize missing optional value on Vercel (#15593)
This updates collecting dynamic route params on Vercel to make sure that missing optional dynamic routes are undefined. Additional tests for this mode have also been added to ensure the params are being collected properly

Closes: https://github.com/vercel/next.js/issues/15579
2020-07-29 14:19:25 +00:00

24 lines
535 B
JavaScript

const path = require('path')
const http = require('http')
const server = http.createServer((req, res) => {
const pagePath = (page) => path.join('.next/serverless/pages/', page)
const render = (page) => {
require(`./${pagePath(page)}`).render(req, res)
}
switch (req.url) {
case '/docs/gssp': {
return render('/gssp.js')
}
default: {
res.statusCode = 404
return res.end('404')
}
}
})
const port = process.env.PORT || 3000
server.listen(port, () => {
console.log('ready on', port)
})