Browsers block a web page from calling an API on a different origin (scheme, host or port) unless the server allows it with CORS headers; this is a browser rule, not a server firewall.
Add CORSMiddleware with the exact allowed origins; the wildcard "*" cannot be combined with credentials (cookies or authorization headers) in browsers.
from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=["https://myapp.com", "http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)