Fix Access-Control-Request-Method header#4424
Conversation
| 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.
Interestingly this seems also wrong 🤔
There was a problem hiding this comment.
Oh, you're right.
There was a problem hiding this comment.
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! |
pranaygp
left a comment
There was a problem hiding this comment.
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-MethodHTTP header for preflight requests doesn't contain the actual request method, but instead the origin.That's not correct.