Skip to content

Commit f0f3075

Browse files
galvezSébastien Chopin
authored andcommitted
Filter out non-strings (serverMiddleware watch fix) (nuxt#3771)
* Filter out non-strings * Add serverMiddleware function * Add serverMiddleware function (2) * Add serverMiddleware function (3)
1 parent b920f22 commit f0f3075

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

lib/builder/builder.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,9 @@ export default class Builder {
643643

644644
watchServer() {
645645
const nuxtRestartWatch = _.concat(
646-
this.options.serverMiddleware.map(this.nuxt.resolveAlias),
646+
this.options.serverMiddleware
647+
.filter(i => typeof i === 'string')
648+
.map(this.nuxt.resolveAlias),
647649
this.options.watch.map(this.nuxt.resolveAlias),
648650
path.join(this.options.rootDir, 'nuxt.config.js')
649651
)

test/fixtures/cli/nuxt.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export default {
2-
serverMiddleware: ['~/middleware.js'],
2+
serverMiddleware: [
3+
'~/middleware.js',
4+
(req, res, next) => next()
5+
],
36
watch: ['~/custom.file'],
47
hooks(hook) {
58
hook('listen', (server, { port, host }) => {

0 commit comments

Comments
 (0)