[BUG] next.config
rewrites result in request URL being rewrite destination
#848
Labels
bug
Something isn't working
Describe the bug
When I have a
rewrite
rule in mynext.config.ts
with a destination to an API route, the request URL received by the API route is that of the destination. This is different behavior from the same app deployed on Vercel (or running the app locally), where the request URL received by the API route corresponds to the originally requested URL from the client.Video demonstration:
demo.mp4
Steps to reproduce
Reproduction repo (this was used for the video above, and can be directly deployed to both Cloudflare and Vercel): https://github.com/arvinpoddar/cloudflare-rewrites-repro
Reproduction steps:
next.config.ts
, create a rewrite rule that rewrites/about
to/api/hello
./api/hello/route.ts
, andconsole.log
the incoming request URL./about
in your browser/about
, which is the originally requested path./api/hello
, which is the destination of the rewrite.Expected behavior
I would expect the request URL to be that of the original client request, rather than the destination of the rewrite. This would be consistent with the app's behavior locally and on Vercel.
@opennextjs/cloudflare version
~1.0.0-beta.0 || ^1.0.0
Wrangler version
^4.13.2
next info output
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020 Available memory (MB): 16384 Available CPU cores: 10 Binaries: Node: 21.6.1 npm: 10.2.4 Yarn: 1.22.22 pnpm: 10.7.0 Relevant Packages: next: 15.3.1 // Latest available version is detected (15.3.1). eslint-config-next: 15.3.1 react: 19.1.0 react-dom: 19.1.0 typescript: 5.8.3 Next.js Config: output: N/A
Additional context
No response
The text was updated successfully, but these errors were encountered: