You're encountering a CORS (Cross-Origin Resource Sharing) issue when trying to access the Webflow API from a browser. The API blocks frontend requests from different origins for security reasons.
1. Understand Webflow API Access Limitations
- The Webflow API is designed to be used server-side, not in the browser.
- If you call the API client-side (e.g., from JavaScript in a Webflow project), the request is blocked due to CORS policy.
- Webflow's API does not include CORS headers like
Access-Control-Allow-Origin
, so browsers will deny access.
2. Use a Server-Side Proxy
- Set up a backend proxy (e.g., Node.js with Express, or even use tools like Vercel Serverless Functions or Cloudflare Workers).
- Make your frontend send the request to your backend; your backend then calls the Webflow API.
- This avoids CORS because the actual API request is made server-to-server — not in the browser.
3. Do Not Embed API Calls in Webflow's Frontend JS
- Avoid using
fetch()
or XMLHttpRequest
directly to https://api.webflow.com
from your site's JavaScript. - Doing so will always result in a CORS error and block the request.
- When making requests to the Webflow API from your backend, include:
- Authorization:
Bearer YOUR_SITE_API_TOKEN
- Content-Type:
application/json
- accept-version: e.g.,
1.0.0
(based on the API version you're using)
5. Use Environment Variables to Secure Your API Key
- Never expose your Webflow API token in client-side code.
- Use environment variables on your backend to keep credentials safe.
Summary
Webflow blocks client-side API calls due to CORS restrictions. Use a server-side proxy to call the API securely and avoid browser-based CORS errors. Always keep your API key server-side to prevent misuse.