From 3c9acea31c84ced868a1bdf403e571ea519a2d67 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 6 Mar 2022 01:46:00 -0800 Subject: [PATCH] Fix CORS configuration. We need to configure this always, but limit the allowed origins for non- dev modes. https://github.com/dcs-liberation/dcs_liberation/issues/2039 --- game/server/app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/game/server/app.py b/game/server/app.py index f308d032..777b2427 100644 --- a/game/server/app.py +++ b/game/server/app.py @@ -37,10 +37,14 @@ app.include_router(tgos.router) app.include_router(waypoints.router) +origins = [] if ServerSettings.get().cors_allow_debug_server: - app.add_middleware( - CORSMiddleware, - allow_origins=["http://localhost:3000"], - allow_methods=["*"], - allow_headers=["*"], - ) + origins.append("http://localhost:3000") + + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_methods=["*"], + allow_headers=["*"], +)