fix: daphne with root-path
This commit is contained in:
parent
cbce88f039
commit
bf65dc8be0
@ -2,18 +2,23 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from app.config import settings as env
|
||||
|
||||
|
||||
def serve() -> None:
|
||||
"""Start the Daphne ASGI server on 0.0.0.0:8080."""
|
||||
daphne_path = str(Path(sys.path[0]) / "daphne")
|
||||
subprocess.run( # noqa: S603
|
||||
[
|
||||
args = [
|
||||
daphne_path,
|
||||
"-b",
|
||||
"0.0.0.0", # noqa: S104
|
||||
"-p",
|
||||
"8080",
|
||||
"app.routing:application",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
]
|
||||
# FORCE_SCRIPT_NAME is a WSGI-only setting; under ASGI Django derives the URL
|
||||
# script prefix from the scope's root_path. Pass the prefix to Daphne so that
|
||||
# reverse()/redirects (e.g. the admin post-login redirect) include it.
|
||||
if env.force_script_name:
|
||||
args += ["--root-path", env.force_script_name.rstrip("/")]
|
||||
args.append("app.routing:application")
|
||||
subprocess.run(args, check=True) # noqa: S603
|
||||
|
||||
Loading…
Reference in New Issue
Block a user