CORS headers
The Access-Control response headers a server uses to tell browsers which origins, methods and headers may be used across origins, and for how long.
In more detail
Allow-Origin names the permitted origin, Allow-Methods and Allow-Headers list what the real request may use, and Max-Age says how many seconds the browser may cache the preflight answer. Credentialed requests also need Access-Control-Allow-Credentials, and then the allowed origin must be named exactly rather than given as a wildcard.
Examples
In the APIs course: The course service copies the one origin it recognises into Allow-Origin instead of answering with a wildcard.Access-Control-Allow-Origin: https://course.exampleAccess-Control-Max-Age: 600Related terms
- CORS — The browser rule set that decides whether web page code from one origin may read a response from a different origin.
- preflight request — An automatic OPTIONS request a browser sends before a cross-origin request that is not simple, to ask the server for permission first.
- origin — The scheme, host and port a web page came from, such as https://app.example, which browsers use to decide what the page may access.
- wildcard — A special character, such as *, that stands for any value or any run of characters when matching names or patterns.
Taught in
- Cookies And CORS — Modern API Architecture: REST, GraphQL & gRPC