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

Sending allowed methods if not requested a specific ones #166

Merged
merged 8 commits into from
Jul 26, 2021

Conversation

LuisEGR
Copy link
Contributor

@LuisEGR LuisEGR commented Jul 22, 2021

When sending an Angular http PUT request, there is not header automatically added access-control-request-methods, and since this is not requesting an specific method, the header access-control-allow-methods is not populated causing a CORS error (Method PUT is not allowed by Access-Control-Allow-Methods in preflight response), so to fix this, in case there is not method requested, all the allowed methods are added as access-control-allow-methods, this fixes this problem.

Captura de Pantalla 2021-07-22 a la(s) 15 24 53

@keroxp
Copy link
Owner

keroxp commented Jul 26, 2021

@LuisEGR Sorry, I don't fully understand what you described.

When sending an Angular http PUT request, there is not header automatically added access-control-request-methods,

Do you mean Angular JS doesn't send preflight request before sending PUT request? Really? Isn't it purely CORS violation?

@LuisEGR
Copy link
Contributor Author

LuisEGR commented Jul 26, 2021

@LuisEGR Sorry, I don't fully understand what you described.

When sending an Angular http PUT request, there is not header automatically added access-control-request-methods,

Do you mean Angular JS doesn't send preflight request before sending PUT request? Really? Isn't it purely CORS violation?

I've just took a deeper look and it does send the pre-flight request correctly, the error itself is the header name, it should be singular access-control-request-method, I've just modified the pull request to reflect that, it works now.

OPTIONS /response/set HTTP/1.1
Host: localhost:8899
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: PUT
Access-Control-Request-Headers: content-type,oaid
Referer: http://localhost:4200/
Origin: http://localhost:4200
Connection: keep-alive

@keroxp
Copy link
Owner

keroxp commented Jul 26, 2021

the error itself is the header name

@LuisEGR Oh, I missed it! 😫

@keroxp keroxp merged commit 97049d2 into keroxp:main Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants