Rewrites manipulate RSC requests breaking client side routing #69296
Labels
bug
Issue was opened via the bug report template.
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Link to the code that reproduces this issue
https://github.com/michael-kleemann/proxy-showcase/blob/main/next.config.mjs
To Reproduce
Setup a simple node app that logs requests on port 3001
Send a RSC request to the app
https://localhost:3000/subpath/3?_rsc=1c0y5
.App on port 3001 does not receive query
?_rsc=1c0y5
Send another request with a different query parameter to the app
https://localhost:3000/subpath/3?foo=bar
.App on port 3001 receives query
?foo=bar
There is also a hosted example that shows the broken routing when RSC requests are being rewritten to another app.
https://proxy-showcase.vercel.app/proxy-opennext-target
The console shows that RSC requests are resolved with a
.rsc
suffix which should normally not be added.Current vs. Expected behavior
Current Behavior:
The RSC request is manipulated in the rewriting process. This breaks functionality when rewriting to another NextJs app is intended. In our case we rewrite a path on our domain to another NextJs App. In this path the client side routing is broken as RSC requests are not resolved correctly. The target app resolves the RSC request with an invalid dynamic route id as a suffix
.rsc
is added to the id.Expected Behavior:
The RSC request is rewritten without any manipulation.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 Binaries: Node: 22.6.0 npm: 10.8.2 Yarn: N/A pnpm: 9.7.1 Relevant Packages: next: 14.2.2 eslint-config-next: 14.2.2 react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.5
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
I've validated that another rewrite mechanism via CDN does not break the client side routing.
Only when rewriting is done by NextJS the routing is broken.
The text was updated successfully, but these errors were encountered: