I have a Java Spring JPA application and I want to allow every mapping (/test, /test/1, /test/1/test, etc) for the host: http://localhost:4200
. However with the following code I get a CORS error on every call.
My main class:
@SpringBootApplication
public class TestApplication implements WebMvcConfigurer
{
public static void main(String[] args)
{
SpringApplication.run(TestApplication.class, args);
}
@Override
public void addCorsMappings(CorsRegistry registry)
{
registry.addMapping("*").allowedMethods("OPTIONS", "GET", "PUT", "POST", "DELETE").allowedOrigins("http://localhost:4200").allowedHeaders("*");
}
}
I tried registry.addMapping("/**").allowedMethods("OPTIONS", "GET", "PUT", "POST", "DELETE").allowedOrigins("http://localhost:4200").allowedHeaders("*");
which works for /test but not for /test/1/test. Do I have to add a mapping for every route? Like: addMaping("/**")
,addMaping("/**/**")
,addMaping("/**/**/**")
or can I have one single mapping to allow every route?