feat(server): allow disabling serve-static middleware (#9365)

closes #9362
This commit is contained in:
Daniel Roe 2021-06-02 14:03:31 +01:00 committed by GitHub
parent b9bfb9df01
commit 40521d0a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,13 +87,15 @@ export default class Server {
this.useMiddleware(createTimingMiddleware(this.options.server.timing)) this.useMiddleware(createTimingMiddleware(this.options.server.timing))
} }
// For serving static/ files to / if (this.options.render.static !== false) {
const staticMiddleware = serveStatic( // For serving static/ files to /
path.resolve(this.options.srcDir, this.options.dir.static), const staticMiddleware = serveStatic(
this.options.render.static path.resolve(this.options.srcDir, this.options.dir.static),
) this.options.render.static
staticMiddleware.prefix = this.options.render.static.prefix )
this.useMiddleware(staticMiddleware) staticMiddleware.prefix = this.options.render.static.prefix
this.useMiddleware(staticMiddleware)
}
// Serve .nuxt/dist/client files only for production // Serve .nuxt/dist/client files only for production
// For dev they will be served with devMiddleware // For dev they will be served with devMiddleware