allow multiple hosts (thanks JC I love you)

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-21 13:15:26 +02:00
parent 37af363a47
commit 05e8dec716
1 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ app.jinja_env.add_extension('jinja2.ext.do')
faulthandler.enable()
app.config['SECRET_KEY'] = environ.get('SECRET_KEY').strip()
app.config["SERVER_NAME"] = environ.get("SITE").strip()
SITE = environ.get("SITE").strip()
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3153600
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower()
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024
@ -84,11 +84,11 @@ def before_request():
with open('/site_settings.json', 'r', encoding='utf_8') as f:
app.config['SETTINGS'] = json.load(f)
### WPD TEMP ####
if request.host != app.config["SERVER_NAME"] and app.config["SERVER_NAME"] != "watchpeopledie.co":
if request.host != SITE and SITE != "watchpeopledie.co":
return {"error": "Unauthorized host provided"}, 403
#### END WPD TEMP ####
# uncomment below after done with WPD migration
# if request.host != app.config["SERVER_NAME"]: return {"error": "Unauthorized host provided."}, 403
# if request.host != SITE: return {"error": "Unauthorized host provided."}, 403
if request.headers.get("CF-Worker"): return {"error": "Cloudflare workers are not allowed to access this website."}, 403
if not app.config['SETTINGS']['Bots'] and request.headers.get("Authorization"): abort(403)
@ -98,7 +98,7 @@ def before_request():
g.inferior_browser = 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua or ' firefox/' in ua
#### WPD TEMP #### temporary WPD migration logic: redirect to /
if request.host == 'watchpeopledie.co' and app.config["SERVER_NAME"] == "watchpeopledie.co":
if request.host == 'watchpeopledie.co' and SITE == "watchpeopledie.co":
request.path = request.path.rstrip('/')
if not request.path: request.path = '/'
if request.path != '/':