mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-27 21:05:34 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user