first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import Request
|
||||
|
||||
from config import get_settings
|
||||
|
||||
|
||||
def public_base_url(request: Request) -> str:
|
||||
"""URL сайта: домен из Dokploy (Host), без прописывания в .env."""
|
||||
settings = get_settings()
|
||||
if settings.site_public_url.strip():
|
||||
return settings.site_public_url.strip().rstrip("/")
|
||||
|
||||
proto = (
|
||||
request.headers.get("x-forwarded-proto")
|
||||
or request.url.scheme
|
||||
or "https"
|
||||
).split(",")[0].strip()
|
||||
host = (
|
||||
request.headers.get("x-forwarded-host")
|
||||
or request.headers.get("host")
|
||||
or request.url.netloc
|
||||
)
|
||||
host = host.split(",")[0].strip()
|
||||
return f"{proto}://{host}".rstrip("/")
|
||||
Reference in New Issue
Block a user