From 4ebc64d13aee93fdbbba88f9ce3cdea688447c1e Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Tue, 28 Jan 2025 20:03:56 -0300 Subject: [PATCH] fix: so, the problem can be somewhere else, becasue map is working fine. And we are trying to find where it is ovveriting issue. Modified main.py with some extra rules. Maybe it is helps --- main.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index db015c87..b252e4c0 100644 --- a/main.py +++ b/main.py @@ -124,12 +124,33 @@ app = Starlette( debug=True, ) +# Define allowed origins based on environment +allowed_origins_dev = ["https://localhost:3000"] # Dev environment +allowed_origins_prod = [ + "https://testing.dscrs.site", # Preview environment + "https://testing.discours.io", # Preview environment +] + +# Add ExceptionHandlerMiddleware app.add_middleware(ExceptionHandlerMiddleware) + +# Add CORS middleware for "dev" mode if "dev" in sys.argv: + print("Running in development mode with CORS for localhost.") app.add_middleware( CORSMiddleware, - allow_origins=["https://localhost:3000"], + allow_origins=allowed_origins_dev, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) +else: + # Add CORS middleware for production/preview mode + print(f"Running in {MODE} mode with CORS for production/preview.") + app.add_middleware( + CORSMiddleware, + allow_origins=allowed_origins_prod, + allow_credentials=True, + allow_methods=["*"], # Allow all HTTP methods + allow_headers=["*"], # Allow all headers + )