Skip to content

spring boot webflux cors

spring boot webflux 允许跨域

java
@Configuration
@EnableWebFlux
public class WebConfig implements WebFluxConfigurer {
 
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 允许 GET POST OPTIONS DELETE 接口跨域
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET","POST", "OPTIONS", "DELETE")
                .maxAge(3600);
    }
 
}

最后更新于: