I recently switched my app over from webmvc to webflux, and tried to configure this
@Configuration
@EnableWebFlux
public class WebConfig implements WebFluxConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*");
}
@Bean
CorsWebFilter corsWebFilter() {
var corsConfig = new CorsConfiguration();
corsConfig.setAllowedOrigins(List.of("*"));
var source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfig);
return new CorsWebFilter(source);
}
}
and also tried adding @CrossOrigin
to my controller.
But I'm still not getting the cross-origin response headers.
Anyone know the fix?