From 2953a01c430c72594ed8256ba7f8755d53d4c8ab Mon Sep 17 00:00:00 2001 From: George Pantazis Date: Sat, 27 May 2017 08:40:15 -0700 Subject: [PATCH] Make file-system based routes optional for custom servers (#914) --- server/config.js | 3 ++- server/index.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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) }