-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Consider supporting PreFlight requests and CORS in Servlet Functional Endpoints #24564
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
Comments
I was under the impression that since the |
We're getting most of it for free, expect for the pre-flight requests. We need in that case to match OPTIONS requests that qualify as pre-flight requests and make sure to match to the corresponding handler. Could you take a look at |
@poutsma, notice how From there One option could be to change the HTTP method of the request before trying to find a route. That would be an easy way to support course with |
Thanks for the pointer, @rstoyanchev! I think it should be possible to get this into the |
Initial testing by @bclozel shows that there is more that needs to be done. |
Uh oh!
There was an error while loading. Please reload this page.
Spring MVC supports CORS with simple and pre-flight requests.
Spring MVC provides support for global CORS handling with a filter, but also local support with
@CorsMapping
annotations or aCorsConfiguration
instance, which is provided toAbstractHandlerMapping
implementations.In the case of Servlet Functional Endpoints, the provided
CorsConfiguration
has no effect on pre-flight requests.Here is a sample application:
We can also set a custom
CorsConfiguration
on theRouterFunctionMapping
.In this case, the following request will not match any handler, and other
HandlerMapping
later in the chain will handle this:Other
HandlerMapping
implementations have additional checks in the request matching infrastructure to check requests withCorstUtils.isPreFlightRequest(request)
. See implementations ofAbstractRequestCondition
and alsoAbstractHandlerMethodMapping
itself.I'm wondering if we should have here additional
RequestPredicates
to locally manage CORS requests, or if existing predicates should look for pre-flight requests and match anyway.The text was updated successfully, but these errors were encountered: