Skip to content

Commit

Permalink
Revamp codespaces support based on #1356
Browse files Browse the repository at this point in the history
  • Loading branch information
masenf committed Nov 3, 2023
1 parent 6e1bce3 commit 04fb972
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},
"postCreateCommand": "/bin/bash -c '/usr/local/bin/pip install poetry'"
}
12 changes: 12 additions & 0 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,18 @@ def _replace_defaults(self, **kwargs):
):
self.deploy_url = f"http://localhost:{kwargs['frontend_port']}"

# If running in Github Codespaces, override API_URL
codespace_name = os.getenv("CODESPACE_NAME")
if "api_url" not in self._non_default_attributes and codespace_name:
GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN = os.getenv(
"GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"
)
if codespace_name:
self.api_url = (
f"https://{codespace_name}-{kwargs.get('backend_port', self.backend_port)}"
f".{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
)

def _set_persistent(self, **kwargs):
"""Set values in this config and in the environment so they persist into subprocess.
Expand Down

0 comments on commit 04fb972

Please sign in to comment.