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

Origin header is missing on request in fetch event #57

Open
jurijzahn8019 opened this issue Mar 19, 2024 · 6 comments
Open

Origin header is missing on request in fetch event #57

jurijzahn8019 opened this issue Mar 19, 2024 · 6 comments

Comments

@jurijzahn8019
Copy link

Hi there,

I have managed to run my js app with winterjs.

I have a csrf Middleware which evaluates request origin header. And I discovered that the header is always undefined.

I added a log statement right away in the event handler to verify it not my request pipeline, and yes header is missing.

Do I miss something?

Thank you in advance and you make a great job!

@syrusakbary
Copy link
Member

Good call! This looks like a bug
@Arshia001 will work on it soon!

@Arshia001
Copy link
Member

@jurijzahn8019 thanks for reporting this!

If my understanding is correct, browsers set the Origin header to the domain name of the page that's currently loaded and caused the fetch call. Since WinterJS is running outside the browser, there is no domain name that can be placed in the Origin header. However, you can always add the header manually (which is normally impossible in browsers AFAIK) like so:

let request = new Request('https://foo.bar');
request.headers.append('Origin', 'https://baz.me');

@jurijzahn8019
Copy link
Author

Hi, thanks, what I mean, is that the header is not present in the event request at all.

@Arshia001
Copy link
Member

Are you referring to FetchEvent.request.headers? I believe we pass request headers to JS code exactly as they are received, so if the header was present when the request was made, it should arrive at the JS event handler. I'll try to reproduce this issue.

@jurijzahn8019
Copy link
Author

Yeah, I have used wasmer btw. Maybe this may be the issue. I don't know.

@Arshia001
Copy link
Member

You're actually right, the origin header does get removed from the request. I'll investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants