Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add CORS for local Jupyter setup #2081

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Add CORS for local Jupyter setup
Jupyter greeted users with "404 - Not found" in the local setup.
  • Loading branch information
MoritzWeber0 committed Dec 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7c0b8ffb38ff75823278a5ae43232c104536a01d
29 changes: 12 additions & 17 deletions backend/capellacollab/core/database/migration.py
Original file line number Diff line number Diff line change
@@ -45,6 +45,12 @@

LOGGER = logging.getLogger(__name__)

DEFAULT_REDIRECT_URL = (
"{CAPELLACOLLAB_SESSIONS_SCHEME}://{CAPELLACOLLAB_SESSIONS_HOST}:{CAPELLACOLLAB_SESSIONS_PORT}"
if not core.LOCAL_DEVELOPMENT_MODE
else "http://localhost:8080"
)


def migrate_db(engine, database_url: str):
if os.getenv("ALEMBIC_CONTEXT") == "1":
@@ -147,11 +153,7 @@ def get_eclipse_session_configuration() -> (
"XPRA_CSP_ORIGIN_HOST": "{CAPELLACOLLAB_ORIGIN_BASE_URL}",
},
redirect_url=(
(
"{CAPELLACOLLAB_SESSIONS_SCHEME}://{CAPELLACOLLAB_SESSIONS_HOST}:{CAPELLACOLLAB_SESSIONS_PORT}"
if not core.LOCAL_DEVELOPMENT_MODE
else "http://localhost:8080"
)
DEFAULT_REDIRECT_URL
+ "{CAPELLACOLLAB_SESSIONS_BASE_PATH}/?floating_menu=0&sharing=1&path={CAPELLACOLLAB_SESSIONS_BASE_PATH}/"
),
cookies={},
@@ -243,11 +245,7 @@ def create_capella_model_explorer_tool(
),
ports=tools_models.HTTPPorts(http=8000, metrics=8000),
redirect_url=(
(
"{CAPELLACOLLAB_SESSIONS_SCHEME}://{CAPELLACOLLAB_SESSIONS_HOST}:{CAPELLACOLLAB_SESSIONS_PORT}"
if not core.LOCAL_DEVELOPMENT_MODE
else "http://localhost:8080"
)
DEFAULT_REDIRECT_URL
+ "{CAPELLACOLLAB_SESSIONS_BASE_PATH}/"
),
)
@@ -363,21 +361,18 @@ def create_jupyter_tool(db: orm.Session) -> tools_models.DatabaseTool:
"JUPYTER_TOKEN": "{CAPELLACOLLAB_SESSION_TOKEN}",
"CSP_ORIGIN_HOST": "{CAPELLACOLLAB_ORIGIN_BASE_URL}",
"JUPYTER_BASE_URL": "{CAPELLACOLLAB_SESSIONS_BASE_PATH}",
"JUPYTER_ALLOW_ORIGIN": DEFAULT_REDIRECT_URL,
},
connection=tools_models.ToolSessionConnection(
methods=[
tools_models.HTTPConnectionMethod(
id="jupyter-direct",
name="Direct Jupyter connection (Browser)",
name="Browser",
description="The only available connection method for Jupyter.",
ports=tools_models.HTTPPorts(http=8888, metrics=9118),
redirect_url=(
(
"{CAPELLACOLLAB_SESSIONS_SCHEME}://{CAPELLACOLLAB_SESSIONS_HOST}:{CAPELLACOLLAB_SESSIONS_PORT}"
if not core.LOCAL_DEVELOPMENT_MODE
else "http://localhost:8080"
)
+ "{CAPELLACOLLAB_SESSIONS_BASE_PATH}/lab?token={CAPELLACOLLAB_SESSION_TOKEN}"
DEFAULT_REDIRECT_URL
+ "{CAPELLACOLLAB_SESSIONS_BASE_PATH}/lab"
),
sharing=tools_models.ToolSessionSharingConfiguration(
enabled=True
Loading