fix(server): replace CORS wildcard fallback with closed localhost list (#283)

server/app.py defaulted to allow_origins=["*"] combined with
allow_credentials=True when cors_origins was not passed. That
combination is invalid per the CORS spec — browsers reject it — and
when used loosely it signals that any cross-origin request with
credentials is allowed, exposing session cookies and auth headers.

The reference config at configs/openjarvis/config.toml binds to
0.0.0.0 without setting cors_origins, so this fallback fired in every
default deployment.

Default to a closed list (Vite dev origin + Tauri webview) instead of
the wildcard. Users who actually need a custom origin already pass it
via cors_origins.

Closes #222
This commit is contained in:
Robby Manihani
2026-04-26 17:08:38 -07:00
committed by GitHub
parent 65a340bb7a
commit f4d544d09e
+9 -1
View File
@@ -181,7 +181,15 @@ def create_app(
from fastapi.middleware.cors import CORSMiddleware
_origins = cors_origins if cors_origins is not None else ["*"]
_origins = (
cors_origins
if cors_origins is not None
else [
"http://localhost:5173",
"http://127.0.0.1:5173",
"tauri://localhost",
]
)
app.add_middleware(
CORSMiddleware,
allow_origins=_origins,