-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Middleware rewrite to edge router handler - Invariant: no match found for request #48295
Comments
Same error message when deployed to Vercel |
I think I'm experiencing something similar but with turbopack. When I include prisma it breaks. I don't think it's considering the runtime flag. /src/app/api/order/route.ts
Error:
Error (if I move prisma up):
|
I believe I'm experiencing the same issue using Turbopack with That being said, I'm not sure why I'm encountering this issue in the first place; I'm not trying to use the edge runtime at all, and this should be running on the Node runtime. I have a feeling that @eblanchette's guess is correct, and the runtime flag is being ignored somehow. I'm not sure if Turbopack lives in a separate repository - or where the next.js integration lives - but I'd be eager to contribute if possible. |
same problem here |
i believe this specifically happens in the next 13.3.0 version the next 13.3.1 version has a different error error rendering: Error: Cannot find module 'http' |
Same here. module.exports = {
async rewrites() {
console.log("rewrites");
return [
{
source: "/test/:path*",
destination: "/api/proxy",
},
];
},
}; Same error: UPDATE: I can confirm that this rewrite issue has been fixed for Thanks @ztanner |
This issue currently breaks usage of nextjs with next intl. hope it gets fixed or if we can get a work around to this issue |
Same issue for me. Switching back to |
Same issue here, using |
Also just bumped into this, forcing it off the edge runtime worked. Looks like the fix for this isn't very complex, would be amazing to get some maintainer eyes on this |
same issue, I would like to stay on the edge runtime, did anyone find a workaround (other than switching to nodejs)? |
I ran into this issue as described here - vercel/ai#740. But I wasn't using middleware and next 14.0.1 works fine, whereas 14.0.2 (re)introduces the issue. |
### What? Rewrites to an edge route currently throw an invariant rather than properly serving up the page that is rewritten to. ### Why? The `NextRequest` object that is provided to the edge route handler contains pathname information only for the "origin" request (e.g., when visiting `/one/example` which rewrites to `/two/example`, the pathname is still `/one/example`. This hits an invariant since the route matcher is unable to find `/one/example` since it does not exist. ### How? This updates the module wrapper to grab the pathname from the route definition rather than the request object. For dynamic segments, we extract them from `request.nextUrl` since we know that even if `nextUrl` is referencing the origin path, the parameters it has are relevant for the rewrite. This adds the `getUtils` utility that's also used in base-server to handle the URL normalization, which also provides an interface for normalizing dynamic params from a `ParsedUrlQuery`. Closes NEXT-1724 Fixes #48295
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. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103 Binaries: Node: 18.12.1 npm: 8.19.2 Yarn: 1.22.18 pnpm: 7.29.3 Relevant packages: next: 13.3.1-canary.5 eslint-config-next: 13.3.0 react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/friendly-paper-t3xyol
To Reproduce
Using the codesandbox or code below
Visit: /one/example
middleware.ts
/app/two/example/route.ts
Describe the Bug
A middleware rewrite to an edge route handler causes an error in the dev server.
Error: Invariant: no match found for request. Pathname '/one/example' should have matched '/two/example'
Expected Behavior
Expect: Middleware to rewrite to /two/example successfully.
Same code works when runtime is set to
nodejs
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: