Skip to content

Security

CORS Policy Builder

Build CORS response headers, preflight responses and detect common configuration errors.

Loading tool…

Find this tool in

About this tool

What is CORS Policy Builder?

Describe which browser origins may read a server's cross-origin responses. Match the policy to the request methods, headers and credentials actually used by the client. The generated headers must be implemented by the responding server; adding CORS settings to the requesting page cannot grant itself permission to read a blocked response.

A worked example

Allow one specific application origin

Example input

https://app.example.com

Expected result

Access-Control-Allow-Origin: https://app.example.com

Configure the named origin rather than a path on that origin. The shown header is one part of the policy, not a complete preflight exchange. Decide separately whether credentials are needed and which methods and headers are permitted. If the response origin varies by request, account for the appropriate cache variation when implementing the server behavior.

Common mistakes and limits

  • CORS controls browser access to responses, not authentication or general network access. The server still needs its own authorization and request protections.
  • A wildcard allowed origin cannot be combined with credentialed browser access in the same way as an explicit origin. Review the generator's validation instead of copying contradictory headers.

Features

What you can do

  • Configure a public or specific allowed origin.
  • Select allowed HTTP methods.
  • Add allowed request headers.
  • Add exposed response headers.
  • Enable credentialed cross-origin requests.
  • Configure Access-Control-Max-Age.
  • Generate Vary: Origin when appropriate.
  • Detect wildcard origins combined with credentials.
  • Detect invalid and comma-separated origins.
  • Warn when allowing the null origin.
  • Validate numeric preflight cache duration.
  • Generate complete CORS response headers.
  • Generate an example HTTP 204 preflight response.
  • Process every policy locally in your browser.

Frequently asked questions

Questions about CORS Policy Builder

What is CORS?

Cross-Origin Resource Sharing is a browser mechanism that allows a server to declare which origins may access a resource from frontend JavaScript.

Can I use * with credentials?

No. Browsers reject a wildcard Access-Control-Allow-Origin value when Access-Control-Allow-Credentials is true.

Can Access-Control-Allow-Origin contain multiple origins?

No. A response must return one matching origin or a wildcard. Servers supporting several origins normally validate the request Origin dynamically.

What is a CORS preflight request?

It is an OPTIONS request sent by the browser to check whether a cross-origin method and its headers are allowed before sending the actual request.

Why should a response include Vary: Origin?

It tells caches that the response may change according to the request Origin, preventing one origin's CORS response from being reused for another.

Does CORS replace authentication?

No. CORS controls browser access to responses. Servers must still authenticate users and authorize every protected operation.

Related tools