Commit 2953a01c authored by George Pantazis's avatar George Pantazis Committed by Arunoda Susiripala

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

parent 56cf8ad0
...@@ -8,7 +8,8 @@ const defaultConfig = { ...@@ -8,7 +8,8 @@ const defaultConfig = {
webpackDevMiddleware: null, webpackDevMiddleware: null,
poweredByHeader: true, poweredByHeader: true,
distDir: '.next', distDir: '.next',
assetPrefix: '' assetPrefix: '',
useFileSystemPublicRoutes: true
} }
export default function getConfig (dir) { export default function getConfig (dir) {
......
...@@ -179,9 +179,11 @@ export default class Server { ...@@ -179,9 +179,11 @@ export default class Server {
'/static/:path+': async (req, res, params) => { '/static/:path+': async (req, res, params) => {
const p = join(this.dir, 'static', ...(params.path || [])) const p = join(this.dir, 'static', ...(params.path || []))
await this.serveStatic(req, res, p) 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 const { pathname, query } = parsedUrl
await this.render(req, res, pathname, query) await this.render(req, res, pathname, query)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment