title: Regex in @CrossOrigin SpringBoot
body: <p>I am trying to define <code>origins</code> which are to be allowed to execute a REST Service. I am working on Java(1.8), SpringBoot (1.5.9). I have tried to implement CORS in 2 ways:  </p>
  
  <pre><code>@CrossOrigin(origins = "http://localhost:8080")
  @RequestMapping(value="/questions")
  public String readCSV() throws IOException, URISyntaxException  {
      /** Some Logic **/
      return str;
  }
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  public class WebConfig extends WebMvcConfigurerAdapter {    
      String origins = "http://localhost:8080";       
      @Override
      public void addCorsMappings(CorsRegistry registry) {
          registry.addMapping("/**")
                  .allowedMethods("GET", "PUT", "POST")
                  .allowedOrigins(origins)
                  .maxAge(3600);
          super.addCorsMappings(registry);
      }
  }
  </code></pre>
  
  <p>Both the above cases works. But I want to change that <code>http://localhost:8080</code> to some meaningful regex, which will match to some particular domain name, but the subdoamin name and the port number may vary.<br>
  For example, let's say the <em>desired domain name</em> is <strong>innovation.com</strong> and few <em>accepted urls</em> would be <strong>we.innovation.com:8081</strong>, <strong>my.innovation.com:8090</strong> etc.<br>
  The problem is, whenever I put some regex instead of the static URLs, it throws CORS error and is not allowed to access the service. Even in the case when I used regex which allows any valid url, it blocks <code>localhost:8080</code>.<br>
  I have tried regex like:<br>
  <code>^((?!-)[A-Za-z0-9-]{1,63}(?&lt;!-)\\.)+innovation.com(:\d{2,4})</code><br>
  <code>^https?://(?:[^./@]+\.)*domain\.com(?![^/])</code><br>
  <code>^(http[s]:\/\/)?([A-Za-z0-9-]{1,63}\\.)+innovation.com(:\d{2,4})</code></p>