title: Spring Data Rest and Cors
body: <p>I am developing a Spring Boot application with a Rest interface and a dart fronted. </p>
  
  <p>The XMLHttpRequest does execute a OPTIONS request which is handled totally correct. After this, the final GET ("/products") request is issued and fails:</p>
  
  <p><em>No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:63343" rel="noreferrer">http://localhost:63343</a>' is therefore not allowed access.</em></p>
  
  <p>After some debugging I have found the following:
  The AbstractHandlerMapping.corsConfiguration is populated for all Subclasses except RepositoryRestHandlerMapping. In the RepositoryRestHandlerMapping no corsConfiguration is present / set at creation time and so it won't get recognized as cors path / resource.<br>
  => No CORS headers attached<br>
  Could that be the problem? How can I set it?  </p>
  
  <p>Configuration classes:</p>
  
  <pre><code>@Configuration
  public class RestConfiguration extends RepositoryRestMvcConfiguration {
  
      @Override
      public void addCorsMappings(CorsRegistry registry) {
          registry.addMapping("/**").allowCredentials(false).allowedOrigins("*").allowedMethods("PUT", "POST", "GET", "OPTIONS", "DELETE").exposedHeaders("Authorization", "Content-Type");
      }
  
     ...
  }
  </code></pre>
  
  <p>I even tried to set the Cors per annotation:</p>
  
  <pre><code>@CrossOrigin( methods = RequestMethod.GET, allowCredentials = "false")
  public interface ProductRepository extends CrudRepository&lt;Product, String&gt; {
  
  
  }
  </code></pre>
  
  <p>Raw request headers:</p>
  
  <pre><code>GET /products HTTP/1.1
  Host: localhost:8080
  Connection: keep-alive
  Cache-Control: max-age=0
  authorization: Basic dXNlcjpwYXNzd29yZA==
  User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36
  Content-Type: application/json
  Accept: */*
  Referer: http://localhost:63343/inventory-web/web/index.html
  Accept-Encoding: gzip, deflate, sdch
  Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
  </code></pre>
  
  <p>Raw response headers:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Content-Type: application/hal+json;charset=UTF-8
  Transfer-Encoding: chunked
  Date: Thu, 30 Jul 2015 15:58:03 GMT
  </code></pre>
  
  <p>Versions used:
  Spring Boot 1.3.0.M2
  Spring 4.2.0.RC2</p>
  
  <p>What do I miss?</p>