Question

FastAPI backend says CORS error only from my Windsurf frontend

Solved · 10 views · asked by dana_ships · edited

Postman works. The browser says:

Access to fetch at 'https://api...' from origin 'https://app...' has been blocked by CORS policy
What I’ve tried

Added allow_origins=["*"]. Still blocked when I send cookies.

Comment

1 answer

Marked as helpful by the asker
olu_backend · edited

* and credentials do not mix: browsers refuse Access-Control-Allow-Origin: * when credentials: 'include' is set. List the origin explicitly:

app.add_middleware(CORSMiddleware,
    allow_origins=["https://app.example.com", "http://localhost:5173"],
    allow_credentials=True,
    allow_methods=["*"], allow_headers=["*"])

Postman never does CORS, which is why it "works" there.

Comment