On this page
What this issue is
CORS stands for Cross-Origin Resource Sharing. An origin is the combination of protocol, domain and port, such as https://www.example.com. When JavaScript on your page calls an API on a different origin, the browser asks that server for permission. The server gives permission with response headers such as Access-Control-Allow-Origin.
If the permission is missing or wrong, the browser blocks your code from using the response and logs an error in the console, for example: Access to fetch at 'https://api.example.com/lead' from origin 'https://www.example.com' has been blocked by CORS policy. The request may still reach the server. Your page just cannot use the answer.
Why it costs you leads or sales
Many funnel steps depend on a script calling an API: sending a lead form to a CRM, checking a postcode, loading shipping rates, adding to a cart, creating a payment session or booking a slot. If CORS blocks that call, the step fails. Visitors usually see a spinner that never ends, a button that does nothing, or a generic error. Most of them leave and you never hear about it.
It also tends to start without warning. A developer changes an API domain, a CDN setting, a redirect or a security plugin, and a flow that worked yesterday breaks for every visitor.
- Ad clickVisitor lands on the page
- Fills in formDetails entered, button clicked
- API callBlocked by CORS policy in the browser
- Thank-you pageNever reached
- Conversion tagNever fires
The visitor does everything right, but the browser blocks the response the page needs.
Example: illustrative numbers for a form that posts to an API on another domain. Traffic stays the same, successful submissions drop to near zero.
How to check if your site has it
Open DevTools on the broken step
In Chrome, Edge or Firefox press F12 (or Cmd+Option+I on Mac) and open the Console tab. Reload the page.
Repeat the action
Submit the form, add to cart or click the button that calls the API.
Look for the CORS message
Typical wording: 'blocked by CORS policy', 'No Access-Control-Allow-Origin header is present' or 'Response to preflight request doesn't pass access control check'.
Inspect the request in the Network tab
Filter by Fetch/XHR. Click the failed request and read the Request URL, status code and Response Headers. Check whether an OPTIONS (preflight) request came first and what it returned.
Test from a clean session
Use a private window with extensions off. Ad blockers can also produce errors that look similar but are a different problem.
| Console message | Likely cause |
|---|---|
| No 'Access-Control-Allow-Origin' header is present | The API does not send the header at all, or an error page or redirect replaced the response |
| The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin | Your site's origin is not on the allowed list (www vs non-www, http vs https, wrong port) |
| Response to preflight request doesn't pass access control check | The OPTIONS request returned an error, a redirect, or lacked allowed methods or headers |
| Request header field ... is not allowed by Access-Control-Allow-Headers | Your code sends a header such as Authorization or Content-Type that the API has not allowed |
| Wildcard '*' cannot be used when credentials mode is 'include' | The API uses * while your request sends cookies; it must name the exact origin |
How to fix it
The fix almost always belongs on the server that receives the call, not in your page. You can't solve it by changing front-end code alone. If you don't control that server (a third-party API), call it from your own backend or use the vendor's supported endpoint instead.
Confirm the exact origin
Copy the origin from the console message. Note www vs non-www, http vs https and any port. The allowed value must match it exactly.
Allow that origin on the API
Send Access-Control-Allow-Origin with your site's origin. Prefer a specific allowlist over * for anything that uses cookies or private data.
Answer the preflight request
For JSON POSTs, custom headers or methods like PUT and DELETE, the browser sends an OPTIONS request first. Return 204 or 200 with Access-Control-Allow-Methods and Access-Control-Allow-Headers, and no redirect.
Send the headers on errors and redirects too
A 4xx or 5xx response without the header looks like a CORS error and hides the real problem. Make sure error responses carry the header.
Avoid redirects on the API URL
Call the final URL directly (https, correct host, trailing slash as required). Preflight requests cannot follow redirects.
Or remove the cross-origin call
Serve the API from the same origin (for example a path like /api on your domain) or proxy it through your server, so no CORS check applies.
Find who sends the request
If your own REST route is called from another domain, use the rest_pre_serve_request filter or the rest_allowed_cors_headers filter in a small plugin, not the theme, and allow only your origin.
Check plugins and the host
Security plugins, caching plugins and some hosts add or strip headers. Check their settings, and purge the cache after changing anything.
Use same-origin endpoints
Call Shopify's own endpoints (such as /cart/add.js) from the storefront domain. A call to the myshopify.com domain from a custom domain can be cross-origin.
Fix third-party apps
If a custom script calls your own API, add the CORS headers there. Shopify does not let you edit headers on its storefront, so contact the app vendor if their endpoint is blocked.
Check Custom HTML tags
Open Preview mode and the console. If a Custom HTML tag runs fetch or XMLHttpRequest to another domain, the destination must allow your site's origin.
Consider a server-side option
Where the vendor offers a supported tag template or server-side endpoint, use it instead of a hand-written browser call.
Check the form action or custom code
Native Webflow forms do not need CORS settings. If custom code calls an external API, add your Webflow domain and your custom domain to the API's allowed origins.
Allow both domains
Add the staging webflow.io origin and the live domain separately, since each is its own origin.
Check custom code on funnel pages
If custom JavaScript calls your own API from a funnel or website page, allow the funnel's custom domain as an origin on that API.
Prefer built-in forms and webhooks
Use the native form and workflow webhook actions where possible, which run server-side and avoid browser CORS checks.
Move the call to backend code
If you use Velo, make the external request from backend web modules with the wix-fetch API instead of from page code, then call that backend function.
Allow your domain on third-party APIs
If an embed or custom element calls an API directly, add your Wix domain to the API's allowed origins.
Review code injection
Check scripts added under Settings, Advanced, Code Injection or in Code Blocks that call external APIs.
Allow your domain on the API
Add your live domain to the API's allowed origins. Squarespace does not let you add response headers to its own pages.
Set headers in your server or framework
Use your framework's CORS middleware (for example the cors package in Express) with an explicit origin list, or set headers in nginx or Apache as shown below.
Handle OPTIONS explicitly
Make sure the OPTIONS route returns 204 with the allow headers and that auth middleware does not reject it.
location /api/ {
add_header Access-Control-Allow-Origin "https://www.example.com" always;
add_header Vary Origin always;
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "https://www.example.com" always;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
add_header Access-Control-Max-Age 86400 always;
return 204;
}
proxy_pass http://app_backend;
}const express = require('express');
const cors = require('cors');
const app = express();
const allowed = ['https://www.example.com', 'https://example.com'];
app.use(cors({
origin(origin, cb) {
if (!origin || allowed.includes(origin)) return cb(null, true);
cb(new Error('Not allowed by CORS'));
},
methods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization']
}));
app.post('/api/lead', (req, res) => res.json({ ok: true }));Blocked
- Console shows 'blocked by CORS policy'
- OPTIONS request fails or redirects
- Form shows a spinner or nothing happens
- No thank-you page, no conversion tag
Allowed
- Response includes Access-Control-Allow-Origin for your origin
- OPTIONS returns 204 with allowed methods and headers
- Form completes and shows a confirmation
- Thank-you page loads and tags fire
How to confirm it's fixed
- Hard-reload the page in a private window and repeat the action that failed
- The console shows no 'blocked by CORS policy' message
- In the Network tab the OPTIONS request returns 200 or 204 and the real request returns the expected status
- The response headers include Access-Control-Allow-Origin with your exact origin
- Test both the www and non-www versions and any staging domain you use
- Test on mobile and in a second browser such as Safari or Firefox
- The thank-you page loads and conversion tags fire
- A test lead or order arrives in your inbox or CRM
How to prevent it happening again
- Keep the list of allowed origins in one place and update it when you add a domain, subdomain or staging site
- Retest forms and checkouts after any change to an API, CDN, proxy, security plugin or domain setup
- Avoid redirects on API URLs, including http to https and trailing-slash redirects
- Prefer same-origin or server-side calls for critical steps such as lead capture
- Watch the console on key funnel steps after each release
- Run a scheduled test of every key journey so a break is caught within hours
How FunnelGuard handles this
FunnelGuard detects this today. Its robot visitor runs your real journeys on a schedule, such as a lead form or checkout, and records console errors on each step. A CORS error shows up as a console error, so a blocked API call is flagged on the step where it happened.
A failure is re-checked from a second region before one alert goes out, by email, Slack, Teams, WhatsApp, webhook or PagerDuty. The alert includes a screenshot and a likely cause. FunnelGuard reports the error it sees; you still need to change the headers on the server that owns the API.
You can start with the Free plan (1 site, 2 journeys, daily checks, no card), or try a paid plan free for 3 days. A free read-only website audit is also available.
Questions people ask
Why is my form not submitting and the console says blocked by CORS policy?
Your page is sending the form data to an API on another origin, and that server did not allow your site in its Access-Control-Allow-Origin header. The browser blocks your script from using the response. Add your exact site origin to the API's allowed origins and make sure it answers the OPTIONS preflight request.
How do I fix 'No Access-Control-Allow-Origin header is present on the requested resource'?
Make the server that receives the request send an Access-Control-Allow-Origin header that matches your site's origin. Also check that the response is not an error page or redirect without the header. If you do not control the server, call it from your own backend instead.
Can I fix a CORS error from the front end only?
No. The browser enforces CORS using headers set by the server, so the fix must be made there. On the front end you can only avoid the problem, for example by calling a same-origin endpoint or a proxy on your own server.
Why does the API work in Postman but fail in the browser?
Postman and curl do not enforce CORS, but browsers do. The API may work for direct requests while still missing the headers browsers need. Check the Network tab for the OPTIONS request and the response headers.
What is a CORS preflight request?
A preflight is an OPTIONS request the browser sends before certain cross-origin calls, such as JSON POSTs or requests with an Authorization header. The server must reply with success and the allowed methods and headers. If it errors or redirects, the real request never runs.
Is using Access-Control-Allow-Origin: * safe?
It is acceptable for public data that needs no cookies or login. It does not work with credentialed requests, and it is risky for private APIs. Use an explicit allowlist of your own origins for anything sensitive.
Why does CORS fail on www but work on the non-www domain?
Origins must match exactly, and www.example.com and example.com are different origins. If only one is in the allowed list, the other is blocked. Add both, or redirect visitors to a single canonical domain.
How can I know when a CORS error starts affecting my funnel?
Run your key journeys on a schedule and watch for console errors on each step. FunnelGuard does this with a robot visitor and alerts you with a screenshot and a likely cause, after re-checking the failure from a second region.
Related issues
- PRF-117Console error on a funnel stepFix guide
- PRF-120JS error only after clicking submit breaks the formFix guide
- PRF-125Content Security Policy blocks a needed script or tagFix guide
- PRF-135Form submits but shows no feedback (silent failure)Fix guide
- PRF-137Error 'Something went wrong' shown after submitFix guide
- PRF-116Uncaught JavaScript exception on page loadFix guide