aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--instance/config.py2
-rw-r--r--newspipe/bootstrap.py11
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
bgstack15