diff --git a/server/config.js b/server/config.js index 81c3664b..af0e64d4 100644 --- a/server/config.js +++ b/server/config.js @@ -8,7 +8,8 @@ const defaultConfig = { webpackDevMiddleware: null, poweredByHeader: true, distDir: '.next', - assetPrefix: '' + assetPrefix: '', + useFileSystemPublicRoutes: true } export default function getConfig (dir) { diff --git a/server/index.js b/server/index.js index a2de7a68..226789e4 100644 --- a/server/index.js +++ b/server/index.js @@ -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) }