From 541c1808bce12fefe73cfaac4420403f65629429 Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Sun, 19 Jan 2025 12:15:15 -0500 Subject: [PATCH] Configure proxy --- main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.py b/main.py index fca4eef..1d13a01 100644 --- a/main.py +++ b/main.py @@ -19,6 +19,7 @@ from bleach.css_sanitizer import CSSSanitizer from flask import Flask, render_template, request, redirect, g, session, abort, \ send_from_directory, flash, get_flashed_messages from werkzeug.utils import secure_filename +from werkzeug.middleware.proxy_fix import ProxyFix DATA_DIR = Path(os.environ["DATA_DIR"]) if "DATA_DIR" in os.environ else Path(".") @@ -41,6 +42,12 @@ app = Flask(__name__) app.secret_key = os.environ["SECRET_KEY"] if "SECRET_KEY" in os.environ else "dev" app.config["MAX_CONTENT_LENGTH"] = 50 * 1024 * 1024 app.logger.addHandler(handler) +if "DATA_DIR" in os.environ: + # Running on server behind proxy + app.wsgi_app = ProxyFix( + app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1 + ) + @app.route("/") def index(): -- 2.39.5