Skip to content

Commit

Permalink
fix: cors
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Dec 9, 2024
1 parent d5dc6c7 commit b50fd60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,8 @@ def get_build_dir(local_target: str, packaged_target: str) -> str:

app = FastAPI(lifespan=lifespan)

ws_cors = (
"*" if config.project.allow_origins[0] == "*" else config.project.allow_origins
)

sio = socketio.AsyncServer(
cors_allowed_origins=ws_cors, cors_credentials=True, async_mode="asgi"
async_mode="asgi"
)

asgi_app = socketio.ASGIApp(
Expand All @@ -202,11 +198,9 @@ def get_build_dir(local_target: str, packaged_target: str) -> str:

app.mount(f"{PREFIX}/ws/socket.io", asgi_app)

http_cors = config.project.allow_origins

app.add_middleware(
CORSMiddleware,
allow_origins=http_cors,
allow_origins=config.project.allow_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/copilot/.chainlit/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ session_timeout = 3600
cache = false

# Authorized origins
allow_origins = ["*"]
allow_origins = ["http://localhost:8080"]

# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
# follow_symlink = false
Expand Down

0 comments on commit b50fd60

Please sign in to comment.