Configure Cross-Origin Resource Sharing (CORS) headers for your API. Generate Access-Control-* headers and Express/Nginx/Apache config with security warnings.
Access-Control-Allow-Origin: https://example.com Vary: Origin Access-Control-Allow-Methods: GET, POST Access-Control-Allow-Headers: Content-Type, Authorization Access-Control-Max-Age: 86400
https://example.com or *Specifies which origin(s) are allowed to read the response. A single specific origin or wildcard *. Cannot be * when credentials are included.
GET, POST, PUTLists the HTTP methods allowed when accessing the resource in cross-origin requests. Applies to preflight requests.
Content-Type, AuthorizationLists request headers that may be used in the actual request. Any header outside the CORS-safelisted set requires explicit listing here.
X-Custom-HeaderLists response headers that browsers are allowed to access from JavaScript. By default only CORS-safelisted headers are exposed.
trueIndicates whether the request can include user credentials (cookies, HTTP authentication, TLS certificates). Requires specific origin, not wildcard.
86400Indicates how long (seconds) the results of a preflight request can be cached. Reduces preflight overhead.
OriginTells caches that the response varies by the Origin header. Required when dynamically setting Access-Control-Allow-Origin to prevent cache poisoning.
marduc812
2026