diff options
author | B. Stack <bgstack15@gmail.com> | 2023-08-30 15:24:17 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-08-30 15:24:43 -0400 |
commit | f02ba6fdf5a9c1b87c8208b9251d51d791922df2 (patch) | |
tree | 1fd356ccd59ede6d75adf810a3b4dd989f3cebef | |
parent | customize css (diff) | |
download | newspipe-f02ba6fdf5a9c1b87c8208b9251d51d791922df2.tar.gz newspipe-f02ba6fdf5a9c1b87c8208b9251d51d791922df2.tar.bz2 newspipe-f02ba6fdf5a9c1b87c8208b9251d51d791922df2.zip |
add support for reverse-proxy in config
-rw-r--r-- | instance/config.py | 2 | ||||
-rw-r--r-- | newspipe/bootstrap.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/instance/config.py b/instance/config.py index af5fe9b9..81f83f12 100644 --- a/instance/config.py +++ b/instance/config.py @@ -10,6 +10,8 @@ PORT = 5000 DEBUG = True API_ROOT = "/api/v2.0" +PREFIX = "/newspipe" + CSRF_ENABLED = True SECRET_KEY = "LCx3BchmHRxFzkEv4BqQJyeXRLXenf" SECURITY_PASSWORD_SALT = "L8gTsyrpRQEF8jNWQPyvRfv7U5kJkD" diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index 12044916..3905cd93 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -44,9 +44,20 @@ def set_logging( handler.setLevel(log_level) logger.setLevel(log_level) +class ReverseProxied(object): + def __init__(self, app, script_name): + self.app = app + self.script_name = script_name + + def __call__(self, environ, start_response): + environ['SCRIPT_NAME'] = self.script_name + return self.app(environ, start_response) + # Create Flask application application = Flask(__name__, instance_relative_config=True) +if "PREFIX" in application.config: + application.wsgi_app = ReverseProxied(application.wsgi_app, script_name=application.config["PREFIX"]) configuration = os.environ.get("NEWSPIPE_CONFIG", False) if configuration == "testing": application.debug = logging.DEBUG |