You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When sending a custom status code using NextResponse.rewrite Next On Pages does not use that code. Instead it always send 200.
Reproduction
Example code;
if(req.nextUrl.href.includes("statusCode")){conststatus=Number(req.nextUrl.searchParams.get("statusCode"));console.log("Middleware should respond with status code:",status);returnNextResponse.rewrite(req.url,{
status,headers: {
...req.headers,"X-Status": String(status),},});}
next-on-pages environment related information
System:
Platform: linux
Arch: x64
Version: #202405300957
173877096822.04~d5f7c84 SMP PREEMPT_DYNAMIC Wed FCPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
Memory: 31 GB
Shell: /bin/zsh
Package Manager Used: npm (10.9.2)
Relevant Packages:
@cloudflare/next-on-pages: 1.13.8
vercel: N/A
next: 15.2.0
Description
When sending a custom status code using
NextResponse.rewrite
Next On Pages does not use that code. Instead it always send 200.Reproduction
Example code;
Example repo;
https://github.com/yoohahn/next-test
When I go to
https://localhost:3333/?statusCode=404
I expect the status code to be 404. That is correct when deploying to Vercel or running locally.If I host in Pages and go to the same URL I expect 404, but I get 200.
https://localhost:8788/?statusCode=404
.Pages Deployment Method
None
Pages Deployment ID
No response
Additional Information
I was trying to set next on pages locally but
e2e
hangs on fixtures and I cant get it to run locally. So sadly I can't fix it my self :(Would you like to help?
The text was updated successfully, but these errors were encountered: