Skip to main content

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.

✓ Wildcard origin detection ✓ Credentials misconfiguration check ✓ Preflight cache optimization

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.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Webhook Tester CORS Policy Builder OpenAPI Validator HTTP Status Code Reference API Request Builder API Response Mock Generator HTTP Status Code Reference WebSocket Tester WebP Converter HTTP Status Code Lookup WebSocket Test Client HTTP Status Code Lookup API Response Time Tester HTTP Methods Reference CORS Header Analyzer OpenAPI Schema Validator CORS Policy Tester OpenAPI Mock Generator API Test Case Generator Core Web Vitals Guide HTTP Headers Analyzer API Response Formatter & Analyzer HTTP API Tester HTTP Security Headers Generator HTTP Status Code Reference Web Vitals Scorer HTTP Header Analyzer Web Vitals Analyzer API Mock Server Config Generator REST API Request Builder HTTP Security Headers Checker API Response Mocker Core Web Vitals Budget Calculator API Rate Limit Calculator CORS Tester CORS Header Tester HTTP Headers Inspector HTTP Code Snippet Generator PWA Manifest Generator HTTP Mock Response Builder HMAC Generator LLM Cost Calculator Caddy Caddyfile Generator HTTP Cache-Control Builder WASM Module Explorer AI Prompt Cost Calculator HTTP/2 Server Push Headers Builder Lighthouse Score Simulator nginx Config Builder Mock Service Worker (MSW) API Mocking Guide Core Web Vitals Calculator Content Security Policy Builder LLM Prompt Cost Calculator HTTP Header Inspector AI Rate Limit Calculator WebAssembly Binary Inspector Web Vitals Budget Planner HTTP Cache Header Builder Prompt Injection Tester GCP Service Account Key Auditor Web Performance Checklist Image Optimizer Checklist API Key Generator AI Doc Generator — Pro Tool AI System Guardian Color Blindness Simulator curl Command Builder .htaccess Generator JSON Diff Viewer JSON Diff JWT Builder JWT Decoder nginx Config Generator Password Strength Checker Developer Utilities Rate Limiter Tester API Changelog Generator Service Worker Generator CSP Header Builder Rate Limit Calculator AWS IAM Policy Validator Haproxy Config Validator WCAG Contrast Checker HTTP Cookie Parser HAR Diff Analyzer SBOM Generator JWT Debugger Pro Vue Component Generator LLM Context Window Calculator LLM Token Counter Dockerfile Linter mTLS Certificate Chain Builder Bundle Size Estimator SSL Certificate Checker Prompt Token Estimator Pulumi Modern IaC Guide Casdoor Docker Layer Optimizer Bundle Size Impact Calculator HTML5 Canvas API Playground Token Context Calculator GraphQL Client Configurator OpenAI Function Calling Generator TTFB Analyzer Token Counter & Cost Estimator AI API Rate Limit Calculator Password Strength Analyzer JWT Decoder & Validator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$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.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →