From 2dfe91f649cb7fae29f63ff70b6d6dc8975bffdd Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Wed, 16 Oct 2024 12:02:21 +0200 Subject: [PATCH] chore(dev): Set default port to 4200 in backend configuration This removed some separate handling with the DEVELOPMENT_MODE variable. Also, the internal session viewer can be used out of the box. --- backend/capellacollab/__main__.py | 10 +++------- backend/capellacollab/config/models.py | 2 +- backend/capellacollab/core/database/migration.py | 13 ++----------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/backend/capellacollab/__main__.py b/backend/capellacollab/__main__.py index f26c124ee0..a96820ea42 100644 --- a/backend/capellacollab/__main__.py +++ b/backend/capellacollab/__main__.py @@ -15,7 +15,6 @@ import capellacollab.projects.toolmodels.backups.runs.interface as pipeline_runs_interface import capellacollab.sessions.metrics as sessions_metrics import capellacollab.settings.modelsources.t4c.license_server.metrics as t4c_metrics -from capellacollab import core # This import statement is required and should not be removed! (Alembic will not work otherwise) from capellacollab.config import config @@ -42,12 +41,9 @@ handlers=[stream_handler, timed_rotating_file_handler], ) -ALLOW_ORIGINS = ( - [f"{config.general.scheme}//{config.general.host}:{config.general.port}"] - + ["http://localhost:4200", "http://127.0.0.1:4200"] - if core.DEVELOPMENT_MODE - else [] -) +ALLOW_ORIGINS = [ + f"{config.general.scheme}://{config.general.host}:{config.general.port}" +] async def startup(): diff --git a/backend/capellacollab/config/models.py b/backend/capellacollab/config/models.py index fdb199bd75..95424f8ea7 100644 --- a/backend/capellacollab/config/models.py +++ b/backend/capellacollab/config/models.py @@ -192,7 +192,7 @@ class GeneralConfig(BaseConfig): examples=["localhost", "capella.example.com"], ) port: int | str = pydantic.Field( - default=8000, + default=4200, description="The port the application should run on.", examples=[8000, 443, 8080], ) diff --git a/backend/capellacollab/core/database/migration.py b/backend/capellacollab/core/database/migration.py index 87943515e1..c781289f33 100644 --- a/backend/capellacollab/core/database/migration.py +++ b/backend/capellacollab/core/database/migration.py @@ -11,7 +11,6 @@ from alembic import migration from sqlalchemy import orm -from capellacollab import core from capellacollab.config import config from capellacollab.core import database from capellacollab.events import crud as events_crud @@ -156,11 +155,7 @@ def get_eclipse_session_configuration() -> ( environment={ "CONNECTION_METHOD": "xpra", "XPRA_SUBPATH": "{CAPELLACOLLAB_SESSIONS_BASE_PATH}", - "XPRA_CSP_ORIGIN_HOST": ( - "http://localhost:4200" - if core.DEVELOPMENT_MODE - else "{CAPELLACOLLAB_ORIGIN_BASE_URL}" - ), + "XPRA_CSP_ORIGIN_HOST": "{CAPELLACOLLAB_ORIGIN_BASE_URL}", }, redirect_url="{CAPELLACOLLAB_SESSIONS_SCHEME}://{CAPELLACOLLAB_SESSIONS_HOST}:{CAPELLACOLLAB_SESSIONS_PORT}{CAPELLACOLLAB_SESSIONS_BASE_PATH}/?floating_menu=0&sharing=1&path={CAPELLACOLLAB_SESSIONS_BASE_PATH}/", cookies={ @@ -277,11 +272,7 @@ def create_jupyter_tool(db: orm.Session) -> tools_models.DatabaseTool: environment={ "JUPYTER_PORT": "8888", "JUPYTER_TOKEN": "{CAPELLACOLLAB_SESSION_TOKEN}", - "CSP_ORIGIN_HOST": ( - "http://localhost:4200" - if core.DEVELOPMENT_MODE - else "{CAPELLACOLLAB_ORIGIN_BASE_URL}" - ), + "CSP_ORIGIN_HOST": "{CAPELLACOLLAB_ORIGIN_BASE_URL}", "JUPYTER_BASE_URL": "{CAPELLACOLLAB_SESSIONS_BASE_PATH}", }, connection=tools_models.ToolSessionConnection(