I am using spring boot 1.5.8 and using below cors filter in application.java to enable CORS rest services to be accessible for UI developer to access from his local machine.
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS")
.allowedHeaders("*", "Access-Control-Allow-Headers", "origin" ,"Content-type","accept", "x-requested-with","x-requested-by") //What is this for?
.allowCredentials(true);
}
};
}
I want to disable this when we move to prod automatically when starting jar in prod mode using -Dspring.profiles.active=prod