1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Make file-system based routes optional for custom servers (#914)

This commit is contained in:
George Pantazis 2017-05-27 08:40:15 -07:00 committed by Arunoda Susiripala
parent 56cf8ad0a3
commit 2953a01c43
2 changed files with 6 additions and 3 deletions

View file

@ -8,7 +8,8 @@ const defaultConfig = {
webpackDevMiddleware: null,
poweredByHeader: true,
distDir: '.next',
assetPrefix: ''
assetPrefix: '',
useFileSystemPublicRoutes: true
}
export default function getConfig (dir) {

View file

@ -179,9 +179,11 @@ export default class Server {
'/static/:path+': async (req, res, params) => {
const p = join(this.dir, 'static', ...(params.path || []))
await this.serveStatic(req, res, p)
},
}
}
'/:path*': async (req, res, params, parsedUrl) => {
if (this.config.useFileSystemPublicRoutes) {
routes['/:path*'] = async (req, res, params, parsedUrl) => {
const { pathname, query } = parsedUrl
await this.render(req, res, pathname, query)
}