mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-04 11:27:13 +00:00
Add applyPlugins for setupMiddleware
This commit is contained in:
parent
365d2d8df6
commit
fb2eddb78b
@ -160,16 +160,14 @@ export default class Renderer extends Tapable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupMiddleware () {
|
setupMiddleware () {
|
||||||
|
// Apply setupMiddleware from modules first
|
||||||
|
this.applyPlugins('setupMiddleware', this.app)
|
||||||
|
|
||||||
// Gzip middleware for production
|
// Gzip middleware for production
|
||||||
if (!this.options.dev && this.options.render.gzip) {
|
if (!this.options.dev && this.options.render.gzip) {
|
||||||
this.useMiddleware(compression(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
|
// Common URL checks
|
||||||
this.useMiddleware((req, res, next) => {
|
this.useMiddleware((req, res, next) => {
|
||||||
// If base in req.url, remove it for the middleware and vue-router
|
// 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
|
// Finally use nuxtMiddleware
|
||||||
this.useMiddleware(this.nuxtMiddleware)
|
this.useMiddleware(this.nuxtMiddleware)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user