[Question] How do I get route values in a CORS preflight request?
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
I am implementing an [ICorsPolicyProvider](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.cors.infrastructure.icorspolicyprovider?view=aspnetcore-7.0) to dynamically determine whether or not a cross-origin request is allowed based on the route values of a GET request.
When a CORS preflight request is received, the route value cannot be retrieved ([GetRouteValue](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.routing.routinghttpcontextextensions.getroutevalue) method returns `null`), probably because the corresponding route is not defined for the OPTIONS method.
The HTTP method used in the actual resource request that follows the preflight request is specified in the `Access-Control-Request-Method` request header.
Therefore, I would think it would be possible to determine the GET route and parse route values based on the request path and the value of this header, but I do not know exactly how to do this.
Contributor guide
Assessment
This issue has not been assessed yet.