From 0051a34ff90e7373966a5e8f51fcfbc70b910e74 Mon Sep 17 00:00:00 2001 From: Guillim Date: Tue, 20 Apr 2021 11:19:28 +0200 Subject: [PATCH] Add root_path option to REST API for reverse proxy deployments (#982) --- rest_api/application.py | 3 ++- rest_api/config.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_api/application.py b/rest_api/application.py index 8fd442bee..952729a54 100644 --- a/rest_api/application.py +++ b/rest_api/application.py @@ -6,6 +6,7 @@ from starlette.middleware.cors import CORSMiddleware from rest_api.controller.errors.http_error import http_error_handler from rest_api.controller.router import router as api_router +from rest_api.config import ROOT_PATH logging.basicConfig(format="%(asctime)s %(message)s", datefmt="%m/%d/%Y %I:%M:%S %p") logger = logging.getLogger(__name__) @@ -14,7 +15,7 @@ logging.getLogger("haystack").setLevel(logging.INFO) def get_application() -> FastAPI: - application = FastAPI(title="Haystack-API", debug=True, version="0.1") + application = FastAPI(title="Haystack-API", debug=True, version="0.1", root_path=ROOT_PATH) # This middleware enables allow all cross-domain requests to the API from a browser. For production # deployments, it could be made more restrictive. diff --git a/rest_api/config.py b/rest_api/config.py index 36f94d05f..72fb0f0d5 100644 --- a/rest_api/config.py +++ b/rest_api/config.py @@ -7,3 +7,4 @@ INDEXING_PIPELINE_NAME = os.getenv("INDEXING_PIPELINE_NAME", "indexing") FILE_UPLOAD_PATH = os.getenv("FILE_UPLOAD_PATH", "./file-upload") LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") +ROOT_PATH = os.getenv("ROOT_PATH", "/")