I am facing CORS problems in my Spring Boot project in combination with Angular.
I am using the following code and annotated it as configuration.
@Configuration
public class WebConfig {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.allowedOrigins("http://localhost:4200");
}
};
}
}
In Angular I am adding this :
Unfortunately I am still getting this error:
None of them did the job.