From 31a3bb080c0116394664c568f1553a6783f93a1c Mon Sep 17 00:00:00 2001 From: Madison Dunitz Date: Thu, 16 Sep 2021 20:16:41 -0700 Subject: [PATCH 1/2] include localhosta and canary env as allowed origins for staging backend --- server/eb/app.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/eb/app.py b/server/eb/app.py index a698e7d50..89250dc6b 100644 --- a/server/eb/app.py +++ b/server/eb/app.py @@ -10,7 +10,6 @@ from flask_talisman import Talisman from flask_cors import CORS - if os.path.isdir("/opt/python/log"): # This is the standard location where Amazon EC2 instances store the application logs. logging.basicConfig( @@ -80,8 +79,13 @@ def _before_adding_routes(app, app_config): web_base_url = server_config.get_web_base_url() if web_base_url: web_base_url_parse = urlparse(web_base_url) - allowed_origin = f"{web_base_url_parse.scheme}://{web_base_url_parse.netloc}" - CORS(app, supports_credentials=True, origins=allowed_origin) + allowed_origins = [f"{web_base_url_parse.scheme}://{web_base_url_parse.netloc}"] + if os.getenv('DEPLOYMENT_STAGE') in ["Staging"]: + allowed_origins.extend([ + "https://canary-cellxgene.dev.single-cell.czi.technology/", + r"^http://localhost:\d+", + ]) + CORS(app, supports_credentials=True, origins=allowed_origins) Talisman( app, From 87edfa4ddaa0b819ee6f15262afe1d7495a3336a Mon Sep 17 00:00:00 2001 From: Madison Dunitz Date: Fri, 17 Sep 2021 13:46:28 -0700 Subject: [PATCH 2/2] Update server/eb/app.py --- server/eb/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/eb/app.py b/server/eb/app.py index 89250dc6b..f794053cf 100644 --- a/server/eb/app.py +++ b/server/eb/app.py @@ -80,7 +80,7 @@ def _before_adding_routes(app, app_config): if web_base_url: web_base_url_parse = urlparse(web_base_url) allowed_origins = [f"{web_base_url_parse.scheme}://{web_base_url_parse.netloc}"] - if os.getenv('DEPLOYMENT_STAGE') in ["Staging"]: + if os.getenv('DEPLOYMENT_STAGE') in ["Staging", "staging"]: allowed_origins.extend([ "https://canary-cellxgene.dev.single-cell.czi.technology/", r"^http://localhost:\d+",