diff --git a/.gitignore b/.gitignore index 962acec..90a9ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -133,4 +133,6 @@ dmypy.json .DS_Store .aider* +# fastgeoapi /pygeoapi-openapi.json +pygeoapi-openapi.yml diff --git a/app/main.py b/app/main.py index 122982c..9e51b3d 100644 --- a/app/main.py +++ b/app/main.py @@ -80,14 +80,15 @@ async def custom_app_exception_handler(request, e): # override pygeoapi os variables os.environ["PYGEOAPI_CONFIG"] = cfg.PYGEOAPI_CONFIG os.environ["PYGEOAPI_OPENAPI"] = cfg.PYGEOAPI_OPENAPI - os.environ["PYGEOAPI_BASEURL"] = cfg.PYGEOAPI_BASEURL if not (os.environ["PYGEOAPI_CONFIG"] and os.environ["PYGEOAPI_OPENAPI"]): logger.error("pygeoapi variables are not configured") raise PygeoapiEnvError("PYGEOAPI_CONFIG and PYGEOAPI_OPENAPI are not set") else: - # fill pygeoapi configuration with fastapi host and port + # fill pygeoapi configuration with host, port, base url and context os.environ["HOST"] = cfg.HOST os.environ["PORT"] = cfg.PORT + os.environ["PYGEOAPI_BASEURL"] = cfg.PYGEOAPI_BASEURL + os.environ["FASTGEOAPI_CONTEXT"] = cfg.FASTGEOAPI_CONTEXT # prepare pygeoapi openapi file if it doesn't exist pygeoapi_conf = Path.cwd() / os.environ["PYGEOAPI_CONFIG"] diff --git a/pygeoapi-config.yml b/pygeoapi-config.yml index 71d4206..55d479b 100644 --- a/pygeoapi-config.yml +++ b/pygeoapi-config.yml @@ -31,7 +31,7 @@ server: bind: host: ${HOST} port: ${PORT} - url: ${PYGEOAPI_BASEURL}/geoapi + url: ${PYGEOAPI_BASEURL}${FASTGEOAPI_CONTEXT} mimetype: application/json; charset=UTF-8 encoding: utf-8 gzip: false