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 does not function in Next.js 13 while using Turbopack #42921

Closed
1 task done
scissorhands26 opened this issue Nov 15, 2022 · 15 comments · Fixed by #58218
Closed
1 task done

Middleware does not function in Next.js 13 while using Turbopack #42921

scissorhands26 opened this issue Nov 15, 2022 · 15 comments · Fixed by #58218
Assignees
Labels
locked Middleware Related to Next.js Middleware. Webpack Related to Webpack with Next.js.

Comments

@scissorhands26
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Wed Mar 2 00:30:59 UTC 2022
Binaries:
  Node: 19.0.0
  npm: 8.19.2
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 13.0.3-canary.4
  eslint-config-next: 13.0.3
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Using next dev --turbo causes middleware not to execute.

Expected Behavior

Using next dev --turbo should not affect middleware execution.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/scissorhands26/nextjs-13-middleware-turbopack-bug

To Reproduce

Use middleware in conjunction with the pages or app directory, and add the --turbo flag to "dev": "next dev --turbo".

@scissorhands26 scissorhands26 added the bug Issue was opened via the bug report template. label Nov 15, 2022
@balazsorban44 balazsorban44 added kind: bug Middleware Related to Next.js Middleware. Turbopack Related to Turbopack with Next.js. and removed bug Issue was opened via the bug report template. labels Nov 15, 2022
@balazsorban44 balazsorban44 removed Turbopack Related to Turbopack with Next.js. kind: bug labels Nov 15, 2022
@balazsorban44 balazsorban44 added kind: bug Webpack Related to Webpack with Next.js. labels Nov 15, 2022
@useafterfree
Copy link

Also observed in this closed issue: vercel/turborepo#2905

@renanrodrigueszup
Copy link

having the same issue in a turborepo environment

@racsogrok
Copy link

I'm experiencing this issue as well. I was looking to build a library that integrates well with Turbopack, but this is the last blocker I'm facing at the moment.

@shakibhasan09
Copy link

Same issue here

@rokob
Copy link

rokob commented Apr 8, 2023

Any update here? I am still seeing this.

@bento-codeing
Copy link

bento-codeing commented Jun 7, 2023

Any update?

@lucaspereirasouzat
Copy link

Waiting for this update

@psidofuturodev

This comment has been minimized.

@yazhouio
Copy link

I encountered the same issue when using next dev --turbo.
If my code is located in the src directory, the middleware does not run.

My solution was to move the app directory and middleware.js to the root directory. This way, the middleware can run.

@daniel-koudouna
Copy link

daniel-koudouna commented Oct 26, 2023

Has there been any progress on this? We are also facing this issue inside a turborepo project on 14.0.0 . Removing the src folder does make the middleware run, but it is not an ideal solution. Is there a flag we should use like --root in this case?

EDIT: I made a new reproduction repo for the latest version: https://github.com/daniel-koudouna/next14-middleware

@gangeshwark
Copy link

Any update on this yet? We are still facing this issue too. We'd like to maintain the existing folder structure.

@digitaltopo
Copy link

+1 seeing the same issue, middleware.ts in /src folder with /app directory and it doesn't get picked up while using --turbo

@Fraank98
Copy link

Fraank98 commented Nov 6, 2023

A year has passed and you still can't use turbo with a middleware...omg

@ForsakenHarmony
Copy link
Contributor

Sorry for the long wait, a fix is in #58218

timneutkens pushed a commit that referenced this issue Nov 10, 2023
### What?

We previously marked `/src/middleware` as a missing page

Fixes #42921

Closes PACK-1926

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Middleware Related to Next.js Middleware. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.