Build a Content-Security-Policy header and audit it for the weaknesses that silently make a policy useless.
CORS Header Builder
Build CORS response headers and catch the configuration mistakes that browsers reject or that expose your API.
- Free
- No sign-up
- Runs in your browser
Input
Exact origins: scheme, host and port, no trailing slash.
Sends cookies and HTTP auth. Cannot be combined with a wildcard origin.
Ready
Everything happens on this device. No upload, no account, no network request.
How to use this tool
- 1
List the exact origins your frontend is served from. The bare domain and the www form are different origins to a browser.
- 2
Copy the generated headers into your server configuration - and return them on the OPTIONS preflight too, not only on the real request.
Questions about CORS Header Builder
Why can I not use a wildcard with credentials?
Because the browser refuses that combination outright - it is a deliberate safety rule. `Access-Control-Allow-Origin: *` with `Allow-Credentials: true` would let any site make authenticated requests with the visitor’s cookies. Compare the request’s Origin against an allowlist and echo back the matching one instead.
Why is my CORS still failing?
Most often the preflight. The browser sends `OPTIONS` before any non-simple request, and if that returns 404, 405 or no CORS headers, the real request never happens. Second most common: the origin does not match exactly - a trailing slash, a missing port, or http against https.
Why can my JavaScript not read a response header?
Because only a handful are exposed by default (Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma). Anything else - including your own `X-Total-Count` - must be listed in `Access-Control-Expose-Headers`. The response arrives intact; the browser just hides those headers from script.
Does CORS protect my API?
No, and this is worth being clear about. CORS protects *browser users* from one site reading another site’s responses. It does nothing against curl, a script, or a server - none of them enforce it. Your API still needs real authentication and authorisation.
Is my data sent anywhere?
No. This tool runs as JavaScript inside your browser tab. There is no network request carrying your input, nothing is written to a server log, and it keeps working with your connection switched off. You can confirm it in the browser’s network panel. That matters more here than elsewhere on the site: developer tools handle tokens, keys and production data.
Related tools
Other tools you might reach for next.
Parse a raw HTTP header block, explain each header, and flag security-relevant and missing ones.
Format and indent JSON, with optional alphabetical key sorting and a precise syntax error when it will not parse.
Strip every byte of insignificant whitespace from JSON and report the saving.
Check that JSON is syntactically valid, report its structure, and flag duplicate keys that JSON.parse accepts silently.
Compare two JSON documents structurally, by path, distinguishing a type change from a value change.
Evaluate a JSONPath expression against a document and see every match with the path that produced it.
Escape text so it can be embedded as a JSON string value, handling control characters and astral code points.