Enable CORS in Spring 5 Webflux?

Dachstein :

How to enable CORS in a Spring 5 Webflux Project?

I cannot find any proper documentation.

Dachstein :

Here is another solution with the Webflux Configurer.

Side Note: Its Kotlin Code (copied from my project) but you can easily translate that to Java Code.

@Configuration
@EnableWebFlux
class WebConfig: WebFluxConfigurer
{
    override fun addCorsMappings(registry: CorsRegistry)
    {
        registry.addMapping("/**")
            .allowedOrigins("*") // any host or put domain(s) here
            .allowedMethods("GET, POST") // put the http verbs you want allow
            .allowedHeaders("Authorization") // put the http headers you want allow
    }
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=428656&siteId=1