Skip to content

Add CORS support for functional style routes for WebFlux [SPR-15567] #20126

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

Closed
spring-projects-issues opened this issue May 19, 2017 · 4 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 19, 2017

Sumanth Chinthagunta opened SPR-15567 and commented

We have annotations support for adding CORS to routes but I cannot find support for adding CORS for functional style routes when using WebFlux.
This capability is critical for consuming REST , SSE APIs from external SPA apps build with Angular or React.


Affects: 5.0 RC1

Issue Links:

Referenced from: commits 1e04cdf

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Indeed, that makes sense, maybe via a CORS WebFilter.

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Fixed via the introduction of [CorsWebFilter](https://github.com/spring-projects/spring-framework/commit/1e04cdfa7e3ac74181efe57e0674abe4690c46a1).

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

I reopen this issue since a cors(CorsConfigurationSource source) method would also make sense in HandlerStrategies.Builder since as of this commit the functional router leverage @EnableWebFlux infrastracture.

Notice that it is already also possible to configure it via @EnableWebFlux + overriding WebFluxConfigurer#addCorsMappings but a dedicated way of configuring it without annotations or WebCorsFilter seems worth to provide.

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

After a deeper look I think what we have currently is in fact ok. WebFilter based approach should be used via HandlerStrategies.Builder for standelone WebFlux server use case, and @EnableWebFlux + overriding WebFluxConfigurer#addCorsMappings is fine for other use cases like Spring Boot apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants