Access-Control-Allow-Origin is an HTTP response header that identifies which foreign origins may access a resource through cross-origin requests. Browsers reject the response when the header is absent or does not allow the requesting origin; Spring Security adds no CORS headers by default. section 10.1
Use the header alongside related CORS controls:
- Access-Control-Allow-Methods limits permitted HTTP methods, such as allowing only POST or GET. section 10.1
- Access-Control-Allow-Headers limits which request headers a cross-origin client may send. section 10.1
- Browsers may send an OPTIONS preflight request before sending the original request. section 10.1
Testing an allowed origin
Send an OPTIONS request with Origin: http://www.example.com and Access-Control-Request-Method: POST, then verify Access-Control-Allow-Origin and Access-Control-Allow-Methods contain the expected values. section 18.7
Figure 10.3 Enabling cross-origin requests. The example.org server adds the Access-Control-Allow-Origin header to specify the origins of the request for which the browser should accept the response. If the domain from which the call was made is enumerated in the origins, the browser accepts the response.
Shows how the server's Access-Control-Allow-Origin value determines whether the browser accepts a cross-origin response. section 10.1

