-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
All POST fetch requests in browser window have Origin: 'null' in headers #7931
Comments
I would also like to know why it is inconsistent with a GET request. If you send a GET request with the same code it will simply not have an origin header at all (somewhat expected it's a |
This issue was raised sometime back, you can find the reason why no origin header is sent for cors GET request here from file scheme.
The fetch spec allows origin header when sending POST request, which you can find here . Closing this out, since its the expected behavior in Electron. You can use custom protocols for this scenario. |
I am sorry, I still don't understand this.
Thanks! |
(I am hoping to understand this so I know why Electron behaves the way it behaves, and also to help other people who will maybe find this issue by google :)) |
Electron discussion there electron/electron#7931 It seems `Origin: 'null'` from electron apps is a feature, not a bug
Electron discussion there electron/electron#7931 It seems `Origin: 'null'` from electron apps is a feature, not a bug
For both the requests origin will not be set initially, as they are treated as same origin requests because of the reason specified in the above linked thread. But just before the request is sent blink sets the origin for non-get and non-head requests here. Hence you see the different behavior.
The value is set by blink, the reason for |
Thanks! That's what I needed to know. |
I've got around this by doing:
|
Managed to get around this (in the context of a web extension though) by conditionally removing |
Run your app on a (local) server (like wamp, xampp, mamp) |
why is the origin header not set for head request ? |
This still isn't fixed yet. We had to follow instructions from @intellix 's instructions. |
this issue is long time ago issue, but I recently found some resources heer. in 414 line you can find that chrome send origin header when it is blank without 'get' or 'head' method |
Expected behavior
I use
fetch
API withmethod: 'POST'
in the browser window and it has something sensible in 'origin' header.Actual behavior
I use
fetch
API withmethod: 'POST'
in the browser window and it has the string 'null' in 'origin' header.How to reproduce
I cloned
electron-quick-start
for a simple repro here (diff)I do a simple request to https://www.example.org 1 second after start (so that the dev tools see it).
When you click on the example.org request and scroll down, you can see the 'origin: null'
I also added logging of headers in the main thread, so you can see that the 'null' is indeed a string (and not "javascript null").
Removing
{method: 'POST'}
causes the Origin: 'null' to go awayNotes
This might actually be a good behavior; however, I want to know why exactly that happens. What is the spec, what is the reasoning behind it. Is it a bug or a feature?
I found some references to string
'null'
hereParticularly in the second link
The text was updated successfully, but these errors were encountered: