fix: remove trailing slash from GET/POST routes to prevent 307→403 redirect

FastAPI's redirect_slashes=True causes GET /api/v1/canvas to 307 redirect
to /api/v1/canvas/ — axios follows the redirect but drops the Authorization
header, resulting in 403. Fixed by declaring routes as empty string instead
of '/' so no redirect is issued. Same fix applied to nodes and edges routes.
Updated all tests to use paths without trailing slashes.
This commit is contained in:
Pouzor
2026-03-07 01:01:24 +01:00
parent a3e6a97404
commit 8a18ded2bc
6 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -10,13 +10,13 @@ from app.schemas.nodes import NodeCreate, NodeResponse, NodeUpdate
router = APIRouter()
@router.get("/", response_model=list[NodeResponse])
@router.get("", response_model=list[NodeResponse])
async def list_nodes(db: AsyncSession = Depends(get_db), _: str = Depends(get_current_user)):
result = await db.execute(select(Node))
return result.scalars().all()
@router.post("/", response_model=NodeResponse, status_code=status.HTTP_201_CREATED)
@router.post("", response_model=NodeResponse, status_code=status.HTTP_201_CREATED)
async def create_node(body: NodeCreate, db: AsyncSession = Depends(get_db), _: str = Depends(get_current_user)):
node = Node(**body.model_dump())
db.add(node)