public class CorsWebFilter extends Object implements 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.
| Constructor and Description |
|---|
CorsWebFilter(CorsConfigurationSource configSource)
Constructor accepting a
CorsConfigurationSource used by the filter
to find the CorsConfiguration to use for each incoming request. |
CorsWebFilter(CorsConfigurationSource configSource,
CorsProcessor processor)
Constructor accepting a
CorsConfigurationSource used by the filter
to find the CorsConfiguration to use for each incoming request and a
custom CorsProcessor to use to apply the matched
CorsConfiguration for a request. |
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<Void> |
filter(ServerWebExchange exchange,
WebFilterChain chain)
Process the Web request and (optionally) delegate to the next
WebFilter through the given WebFilterChain. |
public CorsWebFilter(CorsConfigurationSource configSource)
CorsConfigurationSource used by the filter
to find the CorsConfiguration to use for each incoming request.UrlBasedCorsConfigurationSourcepublic CorsWebFilter(CorsConfigurationSource configSource, CorsProcessor processor)
CorsConfigurationSource used by the filter
to find the CorsConfiguration to use for each incoming request and a
custom CorsProcessor to use to apply the matched
CorsConfiguration for a request.UrlBasedCorsConfigurationSourcepublic reactor.core.publisher.Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain)
WebFilterWebFilter through the given WebFilterChain.