fix: daphne with root-path

This commit is contained in:
Loïc Gremaud 2026-06-20 08:49:21 +02:00
parent cbce88f039
commit bf65dc8be0
Signed by: Legrems
GPG Key ID: D4620E6DF3E0121D

View File

@ -2,18 +2,23 @@ import subprocess
import sys import sys
from pathlib import Path from pathlib import Path
from app.config import settings as env
def serve() -> None: def serve() -> None:
"""Start the Daphne ASGI server on 0.0.0.0:8080.""" """Start the Daphne ASGI server on 0.0.0.0:8080."""
daphne_path = str(Path(sys.path[0]) / "daphne") daphne_path = str(Path(sys.path[0]) / "daphne")
subprocess.run( # noqa: S603 args = [
[ daphne_path,
daphne_path, "-b",
"-b", "0.0.0.0", # noqa: S104
"0.0.0.0", # noqa: S104 "-p",
"-p", "8080",
"8080", ]
"app.routing:application", # 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
check=True, # 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