Locally works.
Production fails.
Cause
Preflight CORS requests.
What happens
Browser sends:
OPTIONS /api/data
Before:
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
Locally works.
Production fails.
Cause
Preflight CORS requests.
What happens
Browser sends:
OPTIONS /api/data
Before:
POST /api/data
If server doesn’t handle OPTIONS → fail.
Minimal fix (ASP.NET example)
app.UseCors(builder =>
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
Why this matters
Ajax failures are often network policy, not JS bugs.