Webflow sync, pageviews & more.
NEW

How can I get Webflow to allow access to the API and stop blocking the cross-origin response with MIME type application/json?

TL;DR
  • Webflow API must be accessed server-side due to CORS restrictions that block browser requests.
  • Set up a backend proxy to handle API requests and securely store your API key using environment variables.

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.

4. Required Headers for Webflow API (from Server)

  • 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.

Rate this answer

Other Webflow Questions