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: Origin header is ignored in 3.25.0 - 3.27.0 versions #4849

Closed
flexchar opened this issue Jan 28, 2024 · 8 comments
Closed

🐛 BUG: Origin header is ignored in 3.25.0 - 3.27.0 versions #4849

flexchar opened this issue Jan 28, 2024 · 8 comments
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working regression Break in existing functionality as a result of a recent change

Comments

@flexchar
Copy link

flexchar commented Jan 28, 2024

Which Cloudflare product(s) does this pertain to?

Workers Runtime

What version(s) of the tool(s) are you using?

3.25.0

What version of Node are you using?

21.5.0

What operating system are you using?

Mac

Describe the Bug

After upgrading to 3.25.0, Origin header is ignored. Downgrading works as expected.

I have a check that worker must NOT respond unless requests come from my whitelisted domain (think of the hot link protection offered by Cloudflare for images). I noticed that after upgrade those headers never make to my worker.

I use Hono and Postman.

I hope there's a clear indication of how the bug was born - if not, please let me know! I will create a tiny reproduction repo. ✌️

Please provide a link to a minimal reproduction

https://github.com/flexchar/workers-sdk-issue-4849

Please provide any relevant error logs

No error logs appear.

@flexchar flexchar added the bug Something that isn't working label Jan 28, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 28, 2024
@penalosa penalosa added the regression Break in existing functionality as a result of a recent change label Jan 29, 2024
@penalosa
Copy link
Contributor

penalosa commented Jan 29, 2024

This should have been fixed in #4812 —could you check if the latest version of Wrangler exhibits the bug?

@penalosa penalosa added the awaiting reporter response Needs clarification or followup from OP label Jan 29, 2024
@afonsocrg
Copy link

@penalosa it looks like it. I stumbled on this issue because I'm having a similar error:

I have a React frontend that is making a request to a worker. The Origin header is correctly set by the browser (localhost:5173), which was further confirmed with wireshark. However, when the worker starts processing the request, the Origin header contains the value of the request url (in my case localhost:8787). Since I'm losing the information about the request origin, it's impossible for me to correctly set the Access-Control-Allow-Origin header, which makes the frontend block every request sent to the backend.

I'm having trouble figuring out why the Origin header needs to be set to the request url, and not to its original value (request.headers.get("Origin")). I would be very grateful if someone could clarify that for me!

I will also comment on that PR, since it may be a more appropriate place to ask this question!
Btw, @penalosa the link you gave to the PR has additional characters (--could), which forwards to a 404 error page.

@flexchar
Copy link
Author

flexchar commented Feb 7, 2024

Hey Somhairle, I never had the issue before so I'm not sure about #4812.

I can confirm it's still an issue in 3.26.0. I had to downgrade to 3.24.0 again. I will make a repro today.

@stefanmaric
Copy link

I'm experiencing this same issue with versions 3.25.0, 3.26.0, and 3.27.0.

@flexchar
Copy link
Author

flexchar commented Feb 7, 2024

Okay, so I made a mistake regarding referer header. It works. I found out about this issue when cors middleware stopped working inside Hono. The middleware only looks for the Origin header thus my confusion. I am sorry for that. I hope we can figure out where origin hides.

The example: https://github.com/flexchar/workers-sdk-issue-4849

@flexchar flexchar changed the title 🐛 BUG: After upgrading to 3.25.0, Origin/Referer headers are ignored. 🐛 BUG: Origin header is ignored in 3.25.0 - 3.27.0 versions Feb 7, 2024
@lrapoport-cf lrapoport-cf added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Feb 8, 2024
@petebacondarwin
Copy link
Contributor

@flexchar - please can you check with the fix in #4950. I.e.

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7843359492/npm-package-wrangler-4950

This should go out in the next release tomorrow.

@petebacondarwin petebacondarwin removed the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Feb 12, 2024
@petebacondarwin petebacondarwin moved this from Untriaged to Other in workers-sdk Feb 12, 2024
@petebacondarwin petebacondarwin added the awaiting reporter response Needs clarification or followup from OP label Feb 12, 2024
@lrapoport-cf lrapoport-cf moved this from Other to Untriaged in workers-sdk Feb 12, 2024
@flexchar
Copy link
Author

I confirm it works as expected, @petebacondarwin. 🤝

@petebacondarwin
Copy link
Contributor

Great! If it's OK I'll close this PR as done and you can expect this to be generally available in the release tomorrow.

@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working regression Break in existing functionality as a result of a recent change
Projects
None yet
Development

No branches or pull requests

6 participants