A CORS (Cross-Origin Resource Sharing) error typically occurs on the server hosting the custom code, not directly within Webflow.
1. What Causes the CORS Error?
- CORS errors happen when a script in your Webflow site tries to fetch data from a different domain (e.g., a REST API or CDN) and the server does not allow requests from your Webflow site's domain.
- Browsers enforce CORS for security, blocking responses unless the server explicitly allows them using CORS headers (e.g.,
Access-Control-Allow-Origin
).
2. Where the Error Happens
- Webflow does not restrict outbound requests from custom code (such as JavaScript embedded via the Embed element or Page Settings).
- The server receiving the request must be configured to accept cross-origin requests from your Webflow domain (e.g.,
https://example.webflow.io
or your custom domain).
3. How to Fix It
- Edit the server handling your API to include appropriate CORS headers like:
Access-Control-Allow-Origin: *
(for general access)- Or
Access-Control-Allow-Origin: https://yourdomain.com
(for restricted access) - If you’re using a third-party API, check if:
- It supports CORS.
- You need to authenticate or whitelist your origin domain.
- Consider using a backend proxy server with CORS enabled if the original API does not support it.
4. Debugging Tips
- Open browser DevTools → Console or Network tab to inspect the CORS error message for exact cause.
- Watch for messages like “No 'Access-Control-Allow-Origin' header present” which confirm it's a server-side issue.
- If the request is “preflighted” (using
OPTIONS
), the server must also handle those OPTIONS requests correctly.
Summary
CORS errors in Webflow are almost always caused by the remote server not allowing cross-origin requests from your site. You must configure the target server to send the correct CORS headers to resolve the issue.