CORS preflight requests is not properly evaluated? + unclear CORS documentation #40616
Closed
1 task done
Labels
area-middleware
Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
feature-cors
This issue is related to CORS
Needs: Author Feedback
The author of this issue needs to respond in order for us to continue investigating this issue.
Is there an existing issue for this?
Describe the bug
When I add CORS to my application and I specify a policy, for example:
Then my browser makes a preflight request to the API using:
Then the ASP.NET Core 6 (latest) returns
I am surprised that the server OK's this request where the allowed methods does not match.
the log from the CORS handlers says everything is fine:
Expected Behavior
So, I am a bit confused that the preflight request to the API with a non-allowed method (POST) is still allowed and the browser does not even seem to block it when I do a AJAX call using some simple test code like:
Followup request after the preflight is still executed and so I am sooo confused when the allowed method missmatch stlil is allowed.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
6.0.201
Anything else?
So, I think also the documentation should be a bit more clear about the responsibilities of the CORS handler and what it actually enforces and when it blocks and not blocks. It seems that i checks if the origin matches, but it seem to when I look at the source code of the handler that the handler just "mirrors" the allowed-methods/headers.
Can I add custom code to actually enforce the preflight and block invalid methods or headers?
So, what does the handler actually block in the incoming preflight origin request?
The text was updated successfully, but these errors were encountered: