Type a tool name, for example "keyword density" or "transcript".
Generate correct CORS (Cross-Origin Resource Sharing) headers for Apache, Nginx, Node.js, and PHP based on your configuration.
Use * for all, or specific domain
This CORS header generator builds the Access-Control-Allow-Origin, methods, headers, max-age and credentials rules your server needs so a browser app on another origin can call your API. Choose your origin, methods and server type, then copy ready-to-paste code for Apache, Nginx, Node.js (Express) or PHP. It is free and needs no sign-in.
CORS headers are HTTP response headers that tell a browser which other websites may read a response from your server. Cross-Origin Resource Sharing exists because browsers enforce the same-origin policy. A script on https://app.example.com cannot read data from https://api.example.com unless the API opts in. An origin is the combination of scheme, host and port, so even http versus https counts as a different origin.
Five response headers do most of the work:
* for any.Before a request that uses PUT or DELETE, sends an Authorization header or posts JSON, the browser first sends an OPTIONS request called a preflight. Your server must answer it with the headers above, or the browser blocks the real request. The familiar console error "No Access-Control-Allow-Origin header is present" means the response did not include that header.
You fill in five fields, pick a server type and click one button to get the configuration. Follow these steps:
* for a public API, or type one origin such as https://example.com.Say your React app runs at https://app.example.com and calls an API that uses cookies for login. Enter that exact origin, keep GET, POST and OPTIONS ticked, add PUT so the app can update records, leave the default headers and Max Age, tick Allow Credentials and select Apache (.htaccess).
The tool returns a block that sets each header inside a check for the Apache headers module. You get an origin line for https://app.example.com, a methods line reading GET, POST, PUT, OPTIONS, a headers line reading Content-Type, Authorization, a max-age line of 86400 and a credentials line set to true. Paste it into the .htaccess file in your API's web root and reload the page that failed.
| Setting | Example value | What the browser does |
|---|---|---|
| Origin | https://app.example.com | Lets only that site read responses |
| Max Age | 86400 | Reuses the preflight result for a day, within browser limits |
| Credentials | true | Sends cookies with requests |
The output is a short server snippet whose values mirror what you entered, so check each line before you deploy it. The right values depend on who will call your API.
Use * only for data that is safe for anyone to read, such as a public JSON feed or a font file. For anything tied to a user account, enter the exact origin of your front end. The tool accepts one origin that includes the scheme and, if needed, the port, and it rejects paths and trailing slashes. https://example.com/ fails, while https://example.com works.
Allow only what your API really uses. A read-only API needs GET, HEAD and OPTIONS. If your front end sends a custom header such as X-Requested-With and it is missing from Allowed Headers, the preflight fails even when everything else is correct. Header names may contain letters, numbers and hyphens.
A higher value means fewer preflight requests and faster repeat calls. Browsers apply their own ceilings, and Chromium-based browsers cap the cache at two hours, so a very large number will not hurt but will not always be honored. Use 0 while you are testing so each change takes effect immediately.
When Allow Credentials is on, browsers refuse a wildcard origin. The generator stops you with a message asking for an explicit origin, which saves you from a configuration that would fail in the browser anyway.
It fits any situation where a browser blocks a cross-origin request and you control the server that sends the response. Typical cases include:
app.example.com to api.example.com.http://localhost:3000 calling a staging API.If you are on Apache and also need redirects, the .htaccess redirect generator produces rules you can place in the same file. Many more utilities like this sit in the web developer tools hub.
Most CORS problems come from small mismatches between what the browser sends and what the server allows. Work through these checks in order.
https://www.example.com and https://example.com are different origins.* with your real origin.After you paste the snippet into a config file, a code diff tool helps you confirm exactly what changed before you deploy. If you edit the output by hand, the code beautifier can tidy the formatting.
The generator covers the standard header set for four server types, and it has a few deliberate boundaries. It accepts one origin or the wildcard, so it cannot produce a list of several allowed origins. Supporting several origins normally means your server code compares the incoming Origin header with an allowed list and echoes back the match, usually with a Vary: Origin header. You would add that logic yourself.
The Nginx output uses add_header lines, which by default apply only to successful and redirect responses, so error pages may lack the headers. It also does not add a dedicated OPTIONS response, so you may need to add one in your location block. If you use Django, the django-cors-headers package manages these settings in your project configuration instead, and this tool does not generate that format. It also cannot check your live site, so test the finished setup in a browser.
Set your origin, methods and server type above, click Generate CORS Headers and copy the result into your server. You will get a clean snippet in seconds, and a clear next step if the browser still complains.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market