diff --git a/fed_reg/config.py b/fed_reg/config.py index e8d6f8a6..b80692e7 100644 --- a/fed_reg/config.py +++ b/fed_reg/config.py @@ -23,6 +23,7 @@ class Settings(BaseSettings): PROJECT_NAME: str = "Federation-Registry" DOMAIN: str = "localhost:8000" API_V1_STR: str = "/api/v1" + ROOT_PATH: str | None = None @validator("API_V1_STR") @classmethod @@ -81,7 +82,11 @@ def create_doc_url(cls, v: Optional[str], values: Dict[str, Any]) -> str: if v: return v protocol = "http" - link = os.path.join(values.get("DOMAIN"), values.get("API_V1_STR")[1:], "docs") + root_path = values.get("ROOT_PATH", "/") + root_path = root_path[1:] if root_path is not None else "" + link = os.path.join( + values.get("DOMAIN"), root_path, values.get("API_V1_STR")[1:], "docs" + ) return f"{protocol}://{link}" # BACKEND_CORS_ORIGINS is a JSON-formatted list of origins diff --git a/fed_reg/main.py b/fed_reg/main.py index be5d096e..e77fc9f2 100644 --- a/fed_reg/main.py +++ b/fed_reg/main.py @@ -43,6 +43,7 @@ summary=summary, title=settings.PROJECT_NAME, version=version, + root_path=settings.ROOT_PATH, ) # if settings.BACKEND_CORS_ORIGINS: # app.add_middleware(