consolelog.tools

CORS Header Generator

Generate CORS headers — raw headers, JSON, Nginx, Apache, or Express — with a live preview and config validation (wildcard + credentials, etc.).

About this ToolHow it works, benefits & use cases

Configure Cross-Origin Resource Sharing once and get the exact headers — or server config — for the stack you deploy on. Enter your allowed origins, methods, request headers and exposed headers as comma-separated lists, set Max-Age, and toggle credentials, then pick an output format: raw Access-Control-* headers, a JSON object of those headers, an Nginx block, an Apache mod_headers block, or Express.js cors middleware code. The output regenerates live as you type. Built-in validation catches the classic mistakes: a wildcard origin combined with credentials is rejected outright, and you get warnings for wildcard origins in production, a Max-Age above 24 hours that browsers may ignore, and non-standard wildcard methods. Quick Permissive, Restrictive and API presets give you sensible starting points. The Nginx and Apache outputs even include origin-matching logic and preflight handling.

How to Use

  1. 1Enter Allowed origins (comma-separated), or use a preset; add Allowed methods like GET, POST, PUT, DELETE.
  2. 2Fill in Allowed headers and any Exposed headers, set Max age (seconds), and toggle "Allow credentials" if cookies/auth must be sent.
  3. 3Choose an Output format: Raw headers, Headers (JSON), Nginx config, Apache config, or Express.js.
  4. 4Read any validation errors or warnings — for example a wildcard origin with credentials is blocked.
  5. 5Click "Generate CORS config", then copy or download the output (file name and type match the format).

Key Benefits

  • Five output formats: raw headers, JSON, Nginx, Apache, and Express.js cors middleware
  • Live preview that updates as you edit origins, methods, headers and options
  • Validation blocks the unsafe wildcard-origin + credentials combination
  • Warnings for production wildcards, over-24h Max-Age, and non-standard wildcard methods
  • Permissive, Restrictive and API presets for fast, sensible starting configs
  • Nginx and Apache outputs include dynamic origin matching and preflight handling
  • Runs entirely in the browser; download uses the correct file name and MIME type per format

Common Use Cases

  • Generating the Access-Control-* headers to return from an API for a known set of front-end origins
  • Producing an Nginx or Apache snippet to enable CORS at the reverse-proxy layer
  • Scaffolding Express cors() middleware options for a Node backend
  • Double-checking that a credentialed CORS setup does not illegally use a wildcard origin
  • Comparing a permissive dev config against a restrictive production config using the presets

CORS configuration

Live preview · headers

Access-Control-Allow-Origin: https://example.com
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 86400

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related guide

Related tools