I am getting the following problem after porting web.xml to java config
No \'Access-Control-Allow-Origin\' header is present on the requested resource. Origi
Following on Omar's answer, I created a new class file in my REST API project called WebConfig.java with this configuration:
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}
}
This allows any origin to access the API and applies it to all controllers in the Spring project.