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

middleware is not used in production with custom server #69257

Open
Mephiztopheles opened this issue Aug 24, 2024 · 0 comments
Open

middleware is not used in production with custom server #69257

Mephiztopheles opened this issue Aug 24, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware.

Comments

@Mephiztopheles
Copy link

Link to the code that reproduces this issue

https://github.com/Mephiztopheles/custom-server-middleware

To Reproduce

  1. Start the application (npm run dev)
  2. Visit localhost:3000 in the browser
  3. Click both links and get redirected
  4. Stop the server and run the build (npm run build)
  5. Start the production server (npm run start)
  6. Visit localhost:3000 again and click both links
  7. Only redirect-2 works (does not work for me in production but might be a different problem then)

Current vs. Expected behavior

I expect the middleware to be used in production too.
If i remove NODE_ENV=production, the middleware is used again, but then next is not running in production mode

Also, I expect the redirects in the config to work in my production environment

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul  5 10:34:03 UTC 2024
  Available memory (MB): 48119
  Available CPU cores: 16
Binaries:
  Node: 22.3.0
  npm: 10.8.1
  Yarn: N/A
  pnpm: 9.4.0
Relevant Packages:
  next: 15.0.0-canary.128 // Latest available version is detected (15.0.0-canary.128).
  eslint-config-next: N/A
  react: 19.0.0-rc-eb3ad065-20240822
  react-dom: 19.0.0-rc-eb3ad065-20240822
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

next start (local), Other (Deployed)

Additional context

I have used the website template from payload cms, which may lead to the redirects from the config not beeing used.

But the middleware is also missing in the default setup, what you can see in my example

@Mephiztopheles Mephiztopheles added the bug Issue was opened via the bug report template. label Aug 24, 2024
@github-actions github-actions bot added the Middleware Related to Next.js Middleware. label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware.
Projects
None yet
Development

No branches or pull requests

1 participant