-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Fix Access-Control-Request-Method header #4424
Fix Access-Control-Request-Method header #4424
Conversation
server/utils.js
Outdated
@@ -42,7 +42,7 @@ export function addCorsSupport (req, res) { | |||
} | |||
|
|||
res.setHeader('Access-Control-Allow-Origin', req.headers.origin) | |||
res.setHeader('Access-Control-Request-Method', req.headers.origin) | |||
res.setHeader('Access-Control-Request-Method', req.method) | |||
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET') | |||
res.setHeader('Access-Control-Allow-Headers', req.headers.origin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly this seems also wrong 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can fix this one too I'll merge the PR 👍
I did some research into this and found that https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method I've updated the PR to reflect this. cc @arunoda please review |
Thanks @timneutkens! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM.
Just to confirm intended behavior, the server now replies saying "Any header you request of me is allowed"? If so, can we not instead just use '*'? https://fetch.spec.whatwg.org/#http-new-header-syntax
I should have linked to MDN as that's why I made the choice not to use There's a
|
Nice catch @timneutkens 🙇♀️ |
* Fix Access-Control-Request-Method header * Make OPTIONS request work
At least since #3578, the
Access-Control-Request-Method
HTTP header for preflight requests doesn't contain the actual request method, but instead the origin.That's not correct.