CORS generator
Build a correct CORS policy and get it as Nginx, Go (Chi/Gin), Express or Caddy config — or paste response headers and see what a browser concludes.
location /api/ {
add_header Access-Control-Allow-Origin "https://app.example.com" always;
add_header Vary "Origin" always;
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "https://app.example.com" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
add_header Access-Control-Max-Age 86400 always;
return 204;
}
# proxy_pass … ;
}CORS that browsers actually accept
Describe the policy once — origins, methods, headers, credentials, preflight cache — and get it as a config for where your edge actually lives: an Nginx location with a map-based origin allowlist, Go middleware for Chi or Gin, the Express cors package, or a Caddyfile block. The generator refuses to produce the combinations browsers reject, like a wildcard origin with credentials.
The analyze mode works backwards: paste the response headers you actually got (from devtools or curl -i) and see what a browser will conclude from them, with the same warnings applied.
Why does my API work in curl but fail in the browser with a CORS error?
Why can't I use * with cookies?
Is CORS a security mechanism for my API?
What does Max-Age actually save?
Related tools: HTTP headers, Security headers and CSP analyzer.