add multiple cross origin urls in spring boot
<p>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?</p>

<pre><code>@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/api/**")
            .allowedOrigins("http://domain1.com")
            .allowedOrigins("http://domain2.com")
            .allowedOrigins("http://domain3.com")
    }
}
</code></pre>

<p>I have no way to test this unless it is used by three domains. But I want to make sure I have three origins set up and not only "domain3.com" is set.</p>

<p><strong>EDIT</strong>: ideal use case for is to inject a list of domains(from application.properties) and set that in allowedOrigins. Is it possible</p>

<p>i.e</p>

<pre><code>  @Value("${domainsList: not configured}")
    private List&lt;String&gt; domains;

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/api/**")
            .allowedOrigins(domains)
    }
}
</code></pre>