Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Issue #284 Add CORS support to handle preflight OPTIONS requests #319

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/canopy_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
Body,
APIRouter
)

from fastapi.middleware.cors import (
CORSMiddleware
)
import uvicorn
from typing import cast, Union, Optional

Expand Down Expand Up @@ -89,6 +93,15 @@ async def lifespan(app: FastAPI):
},
lifespan=lifespan
)

app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)

openai_api_router = APIRouter()
context_api_router = APIRouter(prefix="/context")
application_router = APIRouter(tags=["Application"])
Expand Down