Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addRouteMiddleware is not working in production mode #375

Closed
AndreyYolkin opened this issue Jun 28, 2022 · 1 comment · Fixed by #324
Closed

addRouteMiddleware is not working in production mode #375

AndreyYolkin opened this issue Jun 28, 2022 · 1 comment · Fixed by #324
Assignees
Labels
bug Something isn't working upstream-bug

Comments

@AndreyYolkin
Copy link
Contributor

Environment


  • Operating System: Windows_NT
  • Node Version: v16.14.2
  • Nuxt Version: 2.16.0-27606262.123206cb
  • Package Manager: npm@7.24.1
  • Builder: webpack
  • User Config: modules, bridge, buildModules
  • Runtime Modules: ~/modules/middleware-module
  • Build Modules: @nuxt/bridge@3.0.0-27566698.2b0045e

Reproduction

https://github.com/AndreyYolkin/reproduction/tree/globalMiddleware

Describe the bug

When we try to dynamically insert global route middleware it causes error after running production build. In dev mode everything is ok

Additional context

Error probably locates in this string
after building for production nuxtApp._middleware.global.push turns into nuxtApp._middleware.globalThis.push

I tried to revert this replacement back to 'global' and build became working again

Logs

[nuxt] [request error] Cannot read properties of undefined (reading 'push')
  at addRouteMiddleware (/C:/Projects/reproduction/.output/server/chunks/server.mjs:6816:40)
  at /C:/Projects/reproduction/.output/server/chunks/server.mjs:8519:27
  at callWithNuxt (/C:/Projects/reproduction/.output/server/chunks/server.mjs:6828:24)
  at /C:/Projects/reproduction/.output/server/chunks/server.mjs:6836:30
  at createApp (/C:/Projects/reproduction/.output/server/chunks/server.mjs:8676:15)
  at async __webpack_exports__.default (/C:/Projects/reproduction/.output/server/chunks/server.mjs:8777:11)
  at async renderToString (/C:/Projects/reproduction/.output/server/chunks/renderer.mjs:280:19)
  at async /C:/Projects/reproduction/.output/server/chunks/renderer.mjs:613:20
  at async /C:/Projects/reproduction/.output/server/node_modules/h3/dist/index.mjs:420:19
  at async Server.nodeHandler (/C:/Projects/reproduction/.output/server/node_modules/h3/dist/index.mjs:370:7)
@AndreyYolkin

This comment was marked as outdated.

@danielroe danielroe mentioned this issue Jul 1, 2022
10 tasks
@danielroe danielroe added bug Something isn't working upstream-bug and removed pending triage labels Jul 1, 2022
@danielroe danielroe self-assigned this Jul 4, 2022
danielroe added a commit that referenced this issue Jul 8, 2022
BREAKING CHANGE: `nuxi generate` now behaves differently using nitro prerendering instead of the Nuxt 2 full-static approach. If you would like to keep the Nuxt 2 generation logic while still using nitro, you can run `nuxi generate --classic` or set `bridge.nitroGenerator` to `false`.

resolves #322, resolves #31, resolves #32, resolves #375, resolves #356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants