Skip to content

Commit 8543c1b

Browse files
committed
fix(api): disable redirect_slashes to prevent CORS issues
FastAPI's default redirect_slashes=True was causing 307 redirects that lost the port number, redirecting from :8001 to port 80 (K3s ingress) which blocked requests due to missing CORS headers.
1 parent 2c3d684 commit 8543c1b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

backend/api_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,15 @@ async def lifespan(app: FastAPI):
148148

149149

150150
# Create FastAPI app
151+
# NOTE: redirect_slashes=False prevents 307 redirects that cause CORS issues
152+
# When frontend calls /api/v1/agent/config/ FastAPI would redirect to /api/v1/agent/config
153+
# but the redirect loses the port, going to port 80 (K3s ingress) instead of 8001
151154
app = FastAPI(
152155
title="DreamOps API",
153156
description="Dream easy while AI takes your on-call duty. AI-powered incident response platform with PagerDuty integration.",
154157
version="0.1.0",
155-
lifespan=lifespan
158+
lifespan=lifespan,
159+
redirect_slashes=False
156160
)
157161

158162
# Add CORS middleware

0 commit comments

Comments
 (0)