CORS Policy Validator
Validate your API's CORS headers for security misconfigurations.
Paste the Access-Control-* headers
from your server response and get an instant security analysis: wildcard origin risks, credentials
misconfiguration, missing headers, and preflight optimization hints.
Frequently Asked Questions
What is CORS and why does it matter for security?▼
CORS (Cross-Origin Resource Sharing) is a browser security mechanism that controls which websites can make requests to your API. Without proper CORS configuration, your API could allow any malicious website to make authenticated requests using a visitor's cookies or credentials. A misconfigured CORS policy (like reflecting any Origin or using wildcard with credentials) effectively removes the browser's same-origin protection.
What is the difference between simple and preflighted requests?▼
Simple requests (GET/HEAD/POST with only safelisted headers and content types) are sent directly — the browser checks the CORS headers on the response. Preflighted requests (DELETE, PUT, PATCH, or requests with custom headers) first send an OPTIONS request to check if the actual request is allowed. Your server must respond to OPTIONS with appropriate Access-Control-Allow-* headers. If the preflight fails, the actual request is never sent.
Why is Access-Control-Allow-Origin: * dangerous for APIs with auth?▼
When you respond with Access-Control-Allow-Origin: *, any website can read your API responses. For truly public, read-only APIs this is fine. But combined with Access-Control-Allow-Credentials: true (which allows cookies/auth headers), browsers reject the combination. Attackers exploit misconfigured wildcard origins to perform CSRF-style attacks — they create pages that silently make API calls from victims' browsers. Always use specific origins for authenticated APIs.
What does Access-Control-Allow-Credentials: true enable?▼
By default, cross-origin requests don't include credentials (cookies, HTTP auth headers, client certificates). Setting this header to 'true' tells the browser to include them. This requires: a specific origin (not *), the client JavaScript to set 'credentials: include' on fetch or 'withCredentials: true' on XMLHttpRequest. Enabling this for an authenticated session API is common, but requires a carefully restricted Allow-Origin.
What is Access-Control-Max-Age?▼
This header tells browsers how long to cache the preflight (OPTIONS) response in seconds. Without it, browsers send an OPTIONS request before every cross-origin request, adding latency. Set it to 600 (10 minutes) or 86400 (24 hours, the maximum browsers honor) to cache preflight results. Note: Chrome caps at 7200s (2 hours), Firefox at 86400s.
What should I put in Access-Control-Expose-Headers?▼
By default, JavaScript can only read a limited set of response headers (CORS-safelisted headers: Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified, Pragma). To expose custom headers like X-Request-ID, X-Rate-Limit-Remaining, X-Pagination-*, or Location, list them in Access-Control-Expose-Headers. Without this, fetch response.headers.get('X-Request-ID') returns null even if the header is present.
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
Webhook Tester
Generate realistic webhook test payloads for GitHub, Stripe, Slack, and custom services. Get a curl command to send the payload to your local endpoint. Inspect headers, payload size, and content-type.
Open free tool →
CORS Policy Builder
Generate CORS configuration for Express.js, Nginx, FastAPI, Django, Koa, Laravel, and Spring Boot. Set allowed origins, methods, headers, credentials, and max-age.
Open free tool →
OpenAPI Validator
Paste your OpenAPI 3.x spec (YAML or JSON) to validate structure, find missing required fields, detect duplicate paths, check for missing operationIds, and get errors and warnings with path references.
Open free tool →
More Free Tools
Related Articles
JWT Authentication Best Practices 2026: Secure Your API Tokens
Complete JWT security guide for 2026. Covers RS256 vs HS256 signing, token storage strategies, expiry and refresh token patterns, revocation, common vulnerabilities, and a production security checklist.
JWT Token Decoder: How to Debug Authentication Issues
Learn how to use a JWT token decoder to diagnose 401 errors, expired tokens, missing claims, and auth misconfiguration. Practical debugging guide with code examples.
Base64 Encoding Explained: When to Use It and When to Avoid It
Base64 encoding explained: when to use it in APIs, image data URIs, and auth tokens. Real-world examples and common pitfalls for web developers.
JWT Tokens Explained: How to Decode and Debug Them
Understand JSON Web Tokens from header to signature. Learn how to decode JWTs, read their claims, debug authentication issues, and use free online JWT tools.
HTTP Headers Explained: Security & Performance (2025)
A developer's guide to HTTP headers. Covers security headers (HSTS, CSP, CORS), performance headers (Cache-Control, ETag), and how to inspect headers with free tools.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →