Skip to content
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

[🐛 Bug]: Can't set headers in middleware when receiving request with "RCS: 1" #897

Open
1 task done
SamyPesse opened this issue Oct 25, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@SamyPesse
Copy link

next-on-pages environment related information

System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000
CPU: (10) arm64 Apple M1 Pro
Memory: 16 GB
Shell: /bin/zsh
Package Manager Used: bun (1.1.30)

Relevant Packages:
@cloudflare/next-on-pages: 1.13.5
vercel: N/A
next: N/A

Description

I'm still trying to deep dive into the code of next-on-pages to understand, but it's reproducible when deploying to Cloudflare Pages, but working fine locally with next dev:

In a middleware, when setting headers on the response after a NextResponse.rewrite, these headers are never sent to the end response.

Reproduction

(I'll provide a reproduction asap but wanted to see if people had idea on workaround first)

With middleware that contains:

const response = NextResponse.rewrite(target);
response.headers.set('x-helloworld', 'hello');

return response;

When doing the request GET /, you get the header x-helloworld.

But if you do the request as a router transition/prefetch (reproducible by passing the header RCS: 1), you don't get the header.

Pages Deployment Method

Direct Upload (wrangler pages publish or the @cloudflare/pages-action GitHub Action)

Pages Deployment ID

dd6d6274-8152-412a-8199-18bb44004a0f

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant