CORS error after deploy: Access-Control-Allow-Origin missing
Firefox reports this as "Reason: CORS header 'Access-Control-Allow-Origin' missing"; Chrome shows a similar "blocked by CORS policy" message. The browser blocked the response because your API did not return an Access-Control-Allow-Origin header for your production origin. Configure the API (not the frontend) to allow your deployed domain and to answer OPTIONS preflight requests.
Cause: The server's CORS allowlist still only includes localhost, or the preflight request fails before your handler runs.
How to fix it
- Find the exact origin in the error (scheme + host + port).
- Add that origin to the API's CORS allowlist and redeploy the API.
- Make sure
OPTIONSpreflight returns 2xx with the allowed methods and headers. - If sending cookies, set
Access-Control-Allow-Credentials: trueand a specific origin, never*.
Example
Illustrative example, not from a customer project.
app.use(cors({
- origin: 'http://localhost:5173',
+ origin: ['http://localhost:5173', 'https://app.example.com'],
credentials: true,
}))
FAQ
Can I fix CORS in the frontend?
No. CORS is enforced by the browser based on headers the server sends.
Why not allow `*`?
* cannot be used with credentialed requests and exposes your API to any site.
Get a $149 diagnosis See pricing Launching soon? The Launch Path gets you ready for $1,195 flat.
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- read-only access; fixes arrive as pull requests you merge
- Your $149 diagnosis is credited in full toward any paid job.