Add applyPlugins for setupMiddleware

This commit is contained in:
Sebastien Chopin 2017-06-20 15:32:02 +02:00
parent 365d2d8df6
commit fb2eddb78b

View File

@ -160,16 +160,14 @@ export default class Renderer extends Tapable {
}
setupMiddleware () {
// Apply setupMiddleware from modules first
this.applyPlugins('setupMiddleware', this.app)
// Gzip middleware for production
if (!this.options.dev && this.options.render.gzip) {
this.useMiddleware(compression(this.options.render.gzip))
}
// Add User provided middleware
this.options.serverMiddleware.forEach(m => {
this.useMiddleware(m)
})
// Common URL checks
this.useMiddleware((req, res, next) => {
// If base in req.url, remove it for the middleware and vue-router
@ -223,6 +221,11 @@ export default class Renderer extends Tapable {
}))
}
// Add User provided middleware
this.options.serverMiddleware.forEach(m => {
this.useMiddleware(m)
})
// Finally use nuxtMiddleware
this.useMiddleware(this.nuxtMiddleware)