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.
QUICK FIX · $49 · THIS ERROR ONLY
Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis
- 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.
One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.
Bigger job: Getting the whole app live? Launch Path, $1,195 flat.
Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.