I found an example on how to set cors headers in spring-boot application. Since we have many origins, I need to add them. Is the following valid?
@Configuration
Create your custom annotation and annotate the API with that.
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@CrossOrigin
public @interface CrossOriginsList {
public String[] crossOrigins() default {
"http://domain1.com", "http://domain1.com"
"http://domain1.com", "http://domain1.com"
// Pass as many as you want
};
}
And now Annotate your API with this custom Annotation
@CrossOriginsList
public String methodName() throws Exception
{
//Business Logic
}
Worked perfectly fine for me.!!