bridge: Cannot read property 'handle' of undefined

Cannot read property ‘handle’ of undefined 18:10:26

at Function.use (node_modules\connect\index.js:87:21) at Object.set [as setLegacyMiddleware] (/D:/Dev/footfoot/footfoot-client/node_modules/@nuxt/nitro/dist/index.mjs:1776:13) at /D:/Dev/footfoot/footfoot-client/node_modules/@nuxt/bridge/dist/module.mjs:194:19 at async Nuxt.callHook (node_modules\hable\dist\hable.js:1:959) at async ModuleContainer.ready (node_modules@nuxt\core-edge\dist\core.js:49:5) at async Nuxt._init (node_modules@nuxt\core-edge\dist\core.js:346:5)

╭───────────────────────────────────────────────────────────╮ │ │ │ ✖ Nuxt Fatal Error │ │ │ │ TypeError: Cannot read property ‘handle’ of undefined │ │ │ ╰───────────────────────────────────────────────────────────╯

Environment

Nuxt CLI v3.0.0-27234175.2fb58ae 18:11:56 RootDir: D:\Dev\footfoot\footfoot-client 18:11:57 Nuxt project info: 18:11:57


  • Operating System: Windows_NT
  • Node Version: v14.17.6
  • Nuxt Version: 2.16.0-27226092.034b9901
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: render, pageTransition, serverMiddleware, head, router, loading, generate, css, buildModules, modules, speedkit, cache, pwa, feed, robots, historyState, pruneHtml, axios, sitemap, plugins, workbox, auth, configureWebpack, build, env
  • Runtime Modules: nuxt-helmet@2.0.1, nuxt-custom-headers@2.1.0, nuxt-axios-duplicate-blocker@1.1.1, @nuxtjs/axios@5.13.6, v-sanitize/nuxt, nuxt-brotli@1.1.7, @nuxtjs/proxy@2.1.0, @nuxtjs/auth@4.9.1, cookie-universal-nuxt@2.1.5, @nuxtjs/manifest@3.0.0-beta.16, @nuxtjs/robots@2.5.0, nuxt-lazy-load@1.2.7, nuxt-buefy@0.3.31, nuxt-imagemin@1.0.0, @nuxtjs/component-cache@1.1.6, @nuxtjs/dotenv@1.4.1, nuxt-facebook-pixel-module@1.5.0, nuxt-ssr-cache@1.5.2, @neneos/nuxt-animate.css@0.0.1, @luxdamore/nuxt-prune-html@2.0.6, vue-social-sharing/nuxt, nuxt-font-loader-strategy@1.1.10, nuxt-history-state@0.6.2, nuxt-precompress@0.5.9, nuxt-mobile@1.0.1, @nuxtjs/sitemap@2.4.0, @nuxtjs/feed@2.0.0, nuxt-speedkit@1.3.0
  • Build Modules: @nuxtjs/html-validator@0.5.0, @nuxtjs/router@1.6.1, @nuxtjs/pwa@3.3.5, nuxt-compress@5.0.0, @nuxt/bridge@3.0.0-27234175.2fb58ae

Describe the bug and expected behavior

Running nuxt dev make things crash

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (3 by maintainers)

Most upvoted comments

It is an intentional change, because server middleware need to be able to be compiled into a standalone server.

Modules that want to inject server middleware into the built Nuxt app should add a string pointing to a file rather than directly injecting a function.

The error seems to come from that module in my case : redirect-ssl (https://github.com/unjs/redirect-ssl) @pi0

@danielroe - thanks. If it’s an intentional change, it would be nice if it produced a clearer error, though I guess people will google and find this issue 😃.

In my case it was due to module adding server middleware directly as a function like so: this.addServerMiddleware((req, res, next) => { ... }) instead of explicitly wrapping it in object with handler like so: this.addServerMiddleware({ handler: (req, res, next) => { ... } })

The wrapper was previously added internally both for string or function argument, but in nitro it’s only for string. I don’t know if it is a bug or an intentional change though.

Hello @pi0 i send you an invite thanks for your quick reply