Unleash API has no CORS; browsers must go through a proxy
Shows how to fix unleash API has no CORS; browsers must go through a proxy. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Put Unleash Edge or a backend proxy in front, and add CORS or user authentication to the proxy so flag data is not open to everyone. For server-rendered pages, evaluate flags server-side instead.
Steps
- Never call the Unleash API from browser code directly. Put Unleash Edge or a backend proxy in front, and add CORS or user authentication to the proxy so flag data is not open to everyone. For server-rendered pages, evaluate flags server-side instead.
When to use
You are seeing this: Never call the Unleash API from browser code directly. Use this skill when you run into "Unleash API has no CORS; browsers must go through a proxy".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.