From b19dee359e6cc9e3c63c97e1c7de238924c91bd7 Mon Sep 17 00:00:00 2001 From: Markus Metz <33666869+metzm@users.noreply.github.com> Date: Thu, 8 Sep 2022 17:06:03 +0200 Subject: [PATCH] support nginx with access path (#151) --- src/openeo_grass_gis_driver/capabilities.py | 9 ++------- src/openeo_grass_gis_driver/well_known.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/openeo_grass_gis_driver/capabilities.py b/src/openeo_grass_gis_driver/capabilities.py index f2e506dd..ecac43c9 100644 --- a/src/openeo_grass_gis_driver/capabilities.py +++ b/src/openeo_grass_gis_driver/capabilities.py @@ -205,12 +205,7 @@ def replace_links_in_capabilities(): - host_url = request.host_url.rstrip('/') - split_url = host_url.split('/') - if host_url.startswith('http'): - new_url = "%s//%s" % (split_url[0], split_url[2]) - else: - new_url = split_url[0] + new_url = request.root_url.rstrip('/') for i in CAPABILITIES['links']: sample_url = i['href'] @@ -226,7 +221,7 @@ def replace_links_in_capabilities(): class Capabilities(Resource): def get(self, ): - # links need to be replaced here because host_url + # links need to be replaced here because root_url # is only available during a request CAPABILITIES = replace_links_in_capabilities() return make_response(jsonify(CAPABILITIES), 200) diff --git a/src/openeo_grass_gis_driver/well_known.py b/src/openeo_grass_gis_driver/well_known.py index 84984b3a..2bf694ba 100644 --- a/src/openeo_grass_gis_driver/well_known.py +++ b/src/openeo_grass_gis_driver/well_known.py @@ -22,7 +22,7 @@ def __init__(self): def get(self): - url = '%s%s/' % (request.host_url.strip('/'), URL_PREFIX) + url = '%s%s/' % (request.root_url.strip('/'), URL_PREFIX) version_list = list() version_list.append({"url": url,