diff --git a/web_query_builder/app.py b/web_query_builder/app.py
index 6790e60..c0e5e69 100644
--- a/web_query_builder/app.py
+++ b/web_query_builder/app.py
@@ -1,13 +1,11 @@
+import os
+
from flask import (
Flask,
render_template,
request,
- redirect,
- Response,
)
-import requests
from flask_cors import CORS
-
from werkzeug.middleware.proxy_fix import ProxyFix
app = Flask(__name__)
@@ -28,28 +26,5 @@ config = {}
@app.route("/")
def index():
- return render_template("index.html", request = request, config = config)
-
-
-
-# @app.route('/stac', methods=["GET", "POST"]) # ref. https://medium.com/@zwork101/making-a-flask-proxy-server-online-in-10-lines-of-code-44b8721bca6
-# def redirect_to_API_HOST(): #NOTE var :subpath will be unused as all path we need will be read from :request ie from flask import request
-# url = f'http://localhost:8124/stac'
-# res = requests.request( # ref. https://stackoverflow.com/a/36601467/248616
-# method = request.method,
-# url = url,
-# headers = {k:v for k,v in request.headers if k.lower() != 'host'}, # exclude 'host' header
-# data = request.get_data(),
-# cookies = request.cookies,
-# allow_redirects = False,
-# )
-
-# excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection'] #NOTE we here exclude all "hop-by-hop headers" defined by RFC 2616 section 13.5.1 ref. https://www.rfc-editor.org/rfc/rfc2616#section-13.5.1
-# headers = [
-# (k,v) for k,v in res.raw.headers.items()
-# if k.lower() not in excluded_headers
-# ]
-
-# response = Response(res.content, res.status_code, headers)
-# return response
+ return render_template("index.html", request = request, config = config, api_url = os.environ.get("API_URL", "/api/stac"))
diff --git a/web_query_builder/run.sh b/web_query_builder/run.sh
index dd5bd21..1bf10c5 100755
--- a/web_query_builder/run.sh
+++ b/web_query_builder/run.sh
@@ -1 +1,2 @@
+export API_URL="http://127.0.0.1:8124/api/stac"
flask run --debug --port=5006
\ No newline at end of file
diff --git a/web_query_builder/static/app.js b/web_query_builder/static/app.js
index b7be615..4308da6 100644
--- a/web_query_builder/static/app.js
+++ b/web_query_builder/static/app.js
@@ -5,8 +5,14 @@ function getSTACUrlFromQuery() {
const params = new URLSearchParams(window.location.search);
// get current window url and remove path part
- let api_url = new URL(window.location.href);
- api_url.pathname = "/api/stac";
+ if (window.API_URL.startsWith("http")) {
+ // Absolute URL: Use it directly
+ api_url = new URL(window.API_URL);
+ } else {
+ // Relative URL: Combine with the current window's location
+ api_url = new URL(window.location.href);
+ api_url.pathname = window.API_URL;
+ }
for (const [key, value] of params.entries()) {
api_url.searchParams.set(key, value);
diff --git a/web_query_builder/templates/index.html b/web_query_builder/templates/index.html
index 624c776..7832ef4 100644
--- a/web_query_builder/templates/index.html
+++ b/web_query_builder/templates/index.html
@@ -53,6 +53,9 @@
+