Skip to main content

CORS Header Generator for Nginx, Apache and Express

Pick an origin, methods and headers, get Access-Control-* response headers as a raw list, Nginx, Apache or Express code

  • Runs locally
  • Category Developer & DevOps
  • Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
Custom headers (one per line)
Max-Age (preflight cache, seconds)
Expose-Headers (readable by client JS)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
Access-Control-Max-Age: 86400

What this tool does

Free CORS header generator that turns a few checkboxes into the exact Access-Control-* response headers a browser needs to allow cross-origin requests. Choose Access-Control-Allow-Origin (a wildcard * or one explicit scheme://host:port), tick the methods you actually serve (GET, POST, PUT, DELETE, PATCH, OPTIONS), pick the request headers you accept (Content-Type, Authorization, X-Requested-With and your own custom ones), and decide whether credentialed requests with cookies are allowed. The tool flags the one combination browsers reject outright: Allow-Credentials true together with Allow-Origin *. It also writes Access-Control-Max-Age to cache the preflight and Access-Control-Expose-Headers so client JavaScript can read response headers like X-Total-Count. Output comes in four ready-to-paste formats: a plain header list, an Nginx add_header block, an Apache Header set block and an Express middleware snippet. Everything runs in your browser, nothing is sent anywhere.

Tool details

Input
Text + Numbers
The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
Output
Live result + Copy + Preview
The result area focuses on usable output, with copy, download, or preview actions when supported.
Privacy
Browser-side processing
The main tool logic does not call an external API, so inputs normally stay in the current tab.
Save / share
Shareable URL state
Key settings are encoded in the URL so another person can reopen the same setup.
Performance budget
Initial JS <= 9 KB
No WASM budget is declared, keeping the tool quick to open on mobile.
Best fit
Developer & DevOps · Developer
Category and role tags drive related tools, internal links, and quick fit checks.

How to use

  1. 1. Input

    Paste or drop your content into the tool panel.

  2. 2. Process

    Click the button. All processing is local in your browser.

  3. 3. Copy / Download

    Copy the result or download to disk in one click.

How CORS Header Generator fits into your work

Use it in the small gaps between coding, reviewing, debugging, and shipping.

Developer jobs

  • Formatting, validating, shrinking, or inspecting code-adjacent text.
  • Preparing snippets for documentation, tickets, commits, or handoff.
  • Checking a small payload quickly without switching tools.

Developer checks

  • Run irreversible transforms like minify or obfuscate on a copy.
  • Keep secrets out of pasted snippets unless the tool explicitly stays local.
  • Use your normal tests or linter before shipping transformed code.

Good next steps

These links move the current task into a more complete workflow.

  1. 1 HTTP Header Extractor Extract, dedupe, and export http headers from pasted text or uploaded local files. Open
  2. 2 CSP Policy Auditor Inspect Content-Security-Policy directives for unsafe sources, missing fallbacks, framing gaps, object-src, base-uri, and reporting coverage. Open
  3. 3 HTTP Security Header Auditor Audit raw response headers for HSTS, CSP, cookie flags, MIME sniffing, clickjacking, referrer, and permissions policy gaps. Open

Real-world use cases

  • Let your SPA frontend call your API on another domain

    Your React app on https://app.example.com calls an API on https://api.example.com and the console shows the classic blocked by CORS policy error. Set Access-Control-Allow-Origin to your app origin, tick GET, POST, PUT, DELETE, add Content-Type and Authorization to the allowed headers, turn on credentials so the session cookie rides along, and paste the generated block into Nginx. The preflight clears and the fetch finally returns data instead of an error.

  • Open a public read-only data API to everyone

    You publish a free JSON endpoint that anyone may read from a browser (no cookies, no auth). Pick Allow-Origin * and limit methods to GET and OPTIONS. The tool keeps credentials off so the wildcard stays legal, and you get a one-line Nginx add_header or an Express cors() snippet that any client can hit without you maintaining an origin allowlist.

  • Fix a failing preflight on a PUT or DELETE request

    A simple GET worked but switching to PUT with an Authorization header suddenly fails before the request even leaves the browser. That is the preflight. Add PUT to the methods and Authorization to the headers, set a Max-Age so the browser caches the answer for a day, copy the Apache Header set block into your vhost, and the OPTIONS preflight returns the permissions the browser was waiting for.

  • Expose a pagination header to client-side JavaScript

    Your API returns X-Total-Count so the frontend can render page numbers, but response.headers.get('X-Total-Count') keeps returning null. Add it to Expose-Headers, regenerate, and paste the Express middleware. Now the browser stops hiding the header and the pagination widget reads the total straight off the response.

Common pitfalls

  • Pairing Allow-Origin * with Allow-Credentials true. The browser rejects this combination outright and the request fails with a wildcard-not-allowed error. When you need cookies, echo back one concrete origin validated against an allowlist instead of the wildcard.

  • Forgetting to allow OPTIONS or the custom request headers. A PUT carrying Authorization triggers a preflight; if OPTIONS is not handled or Authorization is missing from Allow-Headers, the real request never fires even though your GET worked fine.

  • Dropping the always flag in Nginx add_header. Without it the CORS header is sent on 2xx responses but not on 4xx or 5xx, so the browser blocks the page from reading even the error body and your debugging gets much harder.

Privacy

Every header is assembled in plain JavaScript inside your browser tab. The origin, methods, custom headers and code snippets you generate never leave the page and nothing is logged. The one caveat: your selections are encoded into the shareable URL query string, so a link you paste into chat will record those options in the recipient server's access log. For an internal origin you would rather not publish, use the copy button and paste the text rather than sharing the URL.

FAQ

Tool combos

Folks in your role tend to reach for these alongside this tool.

Made by Toolora · 100% client-side · Updated 2026-06-14