0
I have a Spring Boot configuration class to handle CORS. This class theoretically allows all origins, all methods and with all headers.
@Configuration
public class CorsConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*").allowedOrigins("*").allowedHeaders("*");
}
}
However, at the front end, I get:
Access to Xmlhttprequest at ːhttp://172.17.178.81:3000/api/v1/token’ from origin ːhttp://172.17. 0.75:8002' has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No Access-Control-Allow-Origin' header is present on the requested Resource.
When I write my endpoint with @Crossorigin, it works normally.
I would like to know what can be done. I don’t believe that annotating every endpoint with @Crossorigin is the right thing to do.
I wrote it down with: @ Configuration (it was already) @ Enablewebmvc @ Componentscan E apparently worked. However, it’s true?
– FearX