[bug] Avoid deleting endpoint port when running on Replit (#3447)
* "if codespace_name" repeated, no-op * Special-case replit.dev * Codifying a ruff future
This commit is contained in:
parent
f672391618
commit
39d9a9f8eb
@ -80,13 +80,13 @@ poetry run pyright reflex tests
|
|||||||
find reflex tests -name "*.py" -not -path reflex/reflex.py | xargs poetry run darglint
|
find reflex tests -name "*.py" -not -path reflex/reflex.py | xargs poetry run darglint
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, run `black` to format your code.
|
Finally, run `ruff` to format your code.
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
poetry run black reflex tests
|
poetry run ruff format .
|
||||||
```
|
```
|
||||||
|
|
||||||
Consider installing git pre-commit hooks so Ruff, Pyright, Darglint and Black will run automatically before each commit.
|
Consider installing git pre-commit hooks so Ruff, Pyright, Darglint and `make_pyi` will run automatically before each commit.
|
||||||
Note that pre-commit will only be installed when you use a Python version >= 3.8.
|
Note that pre-commit will only be installed when you use a Python version >= 3.8.
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
|
@ -316,17 +316,22 @@ class Config(Base):
|
|||||||
):
|
):
|
||||||
self.deploy_url = f"http://localhost:{kwargs['frontend_port']}"
|
self.deploy_url = f"http://localhost:{kwargs['frontend_port']}"
|
||||||
|
|
||||||
|
if "api_url" not in self._non_default_attributes:
|
||||||
# If running in Github Codespaces, override API_URL
|
# If running in Github Codespaces, override API_URL
|
||||||
codespace_name = os.getenv("CODESPACE_NAME")
|
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 = os.getenv(
|
||||||
"GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"
|
"GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"
|
||||||
)
|
)
|
||||||
if codespace_name:
|
# If running on Replit.com interactively, override API_URL to ensure we maintain the backend_port
|
||||||
|
replit_dev_domain = os.getenv("REPLIT_DEV_DOMAIN")
|
||||||
|
backend_port = kwargs.get("backend_port", self.backend_port)
|
||||||
|
if codespace_name and GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN:
|
||||||
self.api_url = (
|
self.api_url = (
|
||||||
f"https://{codespace_name}-{kwargs.get('backend_port', self.backend_port)}"
|
f"https://{codespace_name}-{kwargs.get('backend_port', self.backend_port)}"
|
||||||
f".{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
|
f".{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
|
||||||
)
|
)
|
||||||
|
elif replit_dev_domain and backend_port:
|
||||||
|
self.api_url = f"https://{replit_dev_domain}:{backend_port}"
|
||||||
|
|
||||||
def _set_persistent(self, **kwargs):
|
def _set_persistent(self, **kwargs):
|
||||||
"""Set values in this config and in the environment so they persist into subprocess.
|
"""Set values in this config and in the environment so they persist into subprocess.
|
||||||
|
Loading…
Reference in New Issue
Block a user