diff --git a/config/settings.py b/config/settings.py index 2ebc8b8..545cb78 100644 --- a/config/settings.py +++ b/config/settings.py @@ -26,6 +26,7 @@ class Settings(BaseSettings): host: str = Field(default="0.0.0.0", description="Server bind host") gradio_port: int = Field(default=7860, description="Gradio UI port") api_port: int = Field(default=8000, description="FastAPI port") + root_path: Optional[str] = Field(default=None, description="External URL for reverse proxy (e.g., https://example.com)") # Paths data_dir: Path = Field(default=Path("./data"), description="Data directory") diff --git a/main.py b/main.py index d412677..333819d 100644 --- a/main.py +++ b/main.py @@ -152,12 +152,17 @@ def main(): try: # Gradio 6.x: show_api replaced with footer_links footer = ["api", "gradio"] if settings.api_enabled else ["gradio"] - app.launch( - server_name=settings.host, - server_port=settings.gradio_port, - share=False, - footer_links=footer, - ) + launch_kwargs = { + "server_name": settings.host, + "server_port": settings.gradio_port, + "share": False, + "footer_links": footer, + } + # Add root_path for HTTPS reverse proxy support + if settings.root_path: + launch_kwargs["root_path"] = settings.root_path + logger.info(f"Using root_path: {settings.root_path}") + app.launch(**launch_kwargs) except KeyboardInterrupt: logger.info("Shutting down...") finally: