Class CorsWebFilter
java.lang.Object
org.springframework.web.cors.reactive.CorsWebFilter
- All Implemented Interfaces:
WebFilter
WebFilter that handles CORS preflight requests and intercepts
CORS simple and actual requests thanks to a CorsProcessor implementation
(DefaultCorsProcessor by default) in order to add the relevant CORS
response headers (like Access-Control-Allow-Origin) using the provided
CorsConfigurationSource (for example an UrlBasedCorsConfigurationSource
instance.
This is an alternative to Spring WebFlux Java config CORS configuration, mostly useful for applications using the functional API.
- Since:
- 5.0
- Author:
- Sebastien Deleuze
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCorsWebFilter(CorsConfigurationSource configSource) Constructor accepting aCorsConfigurationSourceused by the filter to find theCorsConfigurationto use for each incoming request.CorsWebFilter(CorsConfigurationSource configSource, CorsProcessor processor) Constructor accepting aCorsConfigurationSourceused by the filter to find theCorsConfigurationto use for each incoming request and a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>filter(ServerWebExchange exchange, WebFilterChain chain) Process the Web request and (optionally) delegate to the nextWebFilterthrough the givenWebFilterChain.
-
Constructor Details
-
CorsWebFilter
Constructor accepting aCorsConfigurationSourceused by the filter to find theCorsConfigurationto use for each incoming request.- See Also:
-
CorsWebFilter
Constructor accepting aCorsConfigurationSourceused by the filter to find theCorsConfigurationto use for each incoming request and a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.- See Also:
-
-
Method Details
-
filter
Description copied from interface:WebFilterProcess the Web request and (optionally) delegate to the nextWebFilterthrough the givenWebFilterChain.
-