CORS builder
Choose origins, methods, headers, and credential behavior for example server responses.
Generate CORS headers, understand browser behavior, and avoid common cross-origin configuration mistakes.
Choose origins, methods, headers, and credential behavior for example server responses.
Copy these examples into server, gateway, or framework configuration and adapt them to real request handling.
https://app.example.comAccess-Control-Allow-Origin: https://app.example.com Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS Access-Control-Allow-Headers: Authorization, Content-Type, Accept Access-Control-Expose-Headers: ETag, RateLimit-Remaining Access-Control-Max-Age: 600
| Header | Value | Browser meaning |
|---|---|---|
Access-Control-Allow-Origin | https://app.example.com | Allows this specific origin to read the response when the browser request matches it. |
Access-Control-Allow-Methods | GET, POST, PUT, PATCH, DELETE, OPTIONS | Lists response methods the browser may use after a successful preflight request. |
Access-Control-Allow-Headers | Authorization, Content-Type, Accept | Lists non-simple request headers the browser may send after preflight approval. |
Access-Control-Expose-Headers | ETag, RateLimit-Remaining | Allows browser JavaScript to read these response headers. |
Access-Control-Max-Age | 600 | Tells browsers how long, in seconds, they may cache a successful preflight response. |
If the request is not simple, the browser sends an OPTIONS preflight before the real request.
The preflight includes Origin, Access-Control-Request-Method, and optionally Access-Control-Request-Headers such as Authorization, Content-Type, Accept.
The response should include this origin plus allowed methods such as GET, POST, PUT, PATCH, DELETE, OPTIONS.
When the preflight matches, the browser proceeds. Otherwise browser JavaScript receives a CORS failure.
Browsers enforce CORS. Your server, CDN, or gateway must return matching headers for the actual Origin, method, request headers, credentials mode, and OPTIONS preflight behavior.
CORS is a browser protocol. It lets servers opt in to selected cross-origin reads while the same-origin policy remains the default boundary.
Browsers compare scheme, host, and port. JavaScript can freely read same-origin responses, but cross-origin reads need matching CORS response headers.
Some GET, HEAD, and POST requests with simple headers may skip preflight, but the final response still needs a matching Access-Control-Allow-Origin.
For methods or headers outside the simple request rules, browsers send OPTIONS first and check allowed method and header responses before continuing.
Cookies, HTTP auth, and client certificates require browser code to request credentials and the server to use an explicit origin plus Access-Control-Allow-Credentials: true.
CORS failures often mean the server skipped OPTIONS, returned the wrong origin, omitted requested headers, or used * with credentials.
This tool generates examples only. Real implementations must compare the request Origin, decide whether to allow it, and return one matching response.
No. It does not perform network requests, fetch URLs, or validate live servers. It only explains behavior and generates local header examples.
No. The response header has one origin value or *. For multiple allowed sites, server code usually checks the request Origin against an allowlist and echoes one match.
Browsers reject Access-Control-Allow-Origin: * together with credentialed CORS. Use a specific origin when cookies, Authorization, or other credentials are involved.
No. CORS is enforced by browsers. APIs still need authentication, authorization, CSRF protection where applicable, input validation, and normal server-side controls.
Many cross-origin browser requests are preflighted. If the server does not answer OPTIONS with matching CORS headers, the browser blocks the real request.