Skip to content

Commit

Permalink
feat(server): allow disabling serve-static middleware (#9365)
Browse files Browse the repository at this point in the history
closes #9362
  • Loading branch information
danielroe committed Jun 2, 2021
1 parent b9bfb9d commit 40521d0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/server/src/server.js
Expand Up @@ -87,13 +87,15 @@ export default class Server {
this.useMiddleware(createTimingMiddleware(this.options.server.timing))
}

// For serving static/ files to /
const staticMiddleware = serveStatic(
path.resolve(this.options.srcDir, this.options.dir.static),
this.options.render.static
)
staticMiddleware.prefix = this.options.render.static.prefix
this.useMiddleware(staticMiddleware)
if (this.options.render.static !== false) {
// For serving static/ files to /
const staticMiddleware = serveStatic(
path.resolve(this.options.srcDir, this.options.dir.static),
this.options.render.static
)
staticMiddleware.prefix = this.options.render.static.prefix
this.useMiddleware(staticMiddleware)
}

// Serve .nuxt/dist/client files only for production
// For dev they will be served with devMiddleware
Expand Down

0 comments on commit 40521d0

Please sign in to comment.