From b75a1c92d160bc9ad97b5a2ba96a8af8216579de Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Wed, 16 Feb 2022 17:00:28 -0500 Subject: handle /set better --- stackbin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stackbin.py b/stackbin.py index 89ec493..2345d5f 100644 --- a/stackbin.py +++ b/stackbin.py @@ -316,11 +316,14 @@ def favicon(): @app.route('/set') def get_proxied_path(): + prefix = "/" if 'HTTP_X_FORWARDED_PREFIX' in request.environ: pl = len(dict(request.headers)["X-Forwarded-Host"].split(", ")) - #prefix = request.environ['HTTP_X_FORWARDED_PREFIX'] + prefix = request.environ['HTTP_X_FORWARDED_PREFIX'] app.wsgi_app = ProxyFix(app.wsgi_app,x_for=pl,x_host=pl,x_port=pl,x_prefix=pl,x_proto=pl) - return redirect(url_for('new_paste')) + # we can afford to use prefix because new_paste is the top-level endpoint of the whole app + message = refresh_string(1, prefix) + "OK" + return message, 200 # stubs, to simplify any templates that ask url_for("login") @app.route('/login/') -- cgit