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
@next/next/no-server-import-in-page throws error on nested _middleware #32156
Comments
I have the same.
|
@matamatanot which version of eslint are you using? I'm on |
I'm able to reproduce this error with I've narrow down the next version where this error first appear to |
This seems to have already been resolved in canary(#32139). |
Hello! Yes it has been fixed and released on v12.0.8-canary.0. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
12.0.7
What version of Node.js are you using?
v12.22.6
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
@next/next/no-server-import-in-page rule throws error on nested _middleware.js.
Error: next/server should not be imported outside of pages/_middleware.js. See https://nextjs.org/docs/messages/no-server-import-in-page. @next/next/no-server-import-in-page
Expected Behavior
This rules should behave the same way for nested and root _middleware.js
To Reproduce
Create 2 _middleware.js, one in
./pages/_middleware.js
and the other in./pages/nested/_middleware.js
with the same code and importimport { NextResponse } from "next/server";
.Code Example: https://replit.com/@francofantini/no-server-import-in-page-bug
Run
npm run lint
on this repo and you'll see that the rule@next/next/no-server-import-in-page
fails for./pages/link/_middleware.js
but not for./pages/_middleware.js
.The text was updated successfully, but these errors were encountered: