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:
parent
56cf8ad0a3
commit
2953a01c43
|
@ -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 {
|
||||||
'/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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue