Two other attempts which didn't work out: ```@Conf...
# spring
p
Two other attempts which didn't work out:
Copy code
@Configuration
class CorsConfig : WebMvcConfigurer {
    override fun addCorsMappings(registry: CorsRegistry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD")
                .allowCredentials(true)
    }
}
Copy code
@Bean
fun cors(): FilterRegistrationBean<CorsFilter> {
    val source = UrlBasedCorsConfigurationSource()
    val config = CorsConfiguration()
    config.setAllowCredentials(true)
    config.setAllowedOrigins(Collections.singletonList("*"))
    config.setAllowedMethods(Collections.singletonList("*"))
    config.setAllowedHeaders(Collections.singletonList("*"))
    source.registerCorsConfiguration("/**", config)
    val bean = FilterRegistrationBean(CorsFilter(source))
    bean.setOrder(0)
    return bean
}