rsnext/test/integration/basepath/server.js
JJ Kasper 3d6d033a5b
Normalize asPath between SSR and CSR with basePath (#14040)
To make `asPath` consistent with `basePath` handling this makes sure it is always stripped including on the client under the `asPath` value and from `req.url` in the `serverless-loader`. Additional tests have been added for this behavior to ensure we don't regress on this

Closes: https://github.com/vercel/next.js/issues/14037
Closes: https://github.com/vercel/next.js/issues/14039
2020-06-11 14:06:06 +00:00

24 lines
534 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)
})