Skip to content

Instantly share code, notes, and snippets.

@snivas
Created October 31, 2019 17:11
Show Gist options
  • Save snivas/2289741d544f594febcd569775dbbac1 to your computer and use it in GitHub Desktop.
Save snivas/2289741d544f594febcd569775dbbac1 to your computer and use it in GitHub Desktop.
def attach_handler(app):
from flask import redirect, url_for
app.wsgi_app = CustomProxyFix(app.wsgi_app)
class CustomProxyFix(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
host = environ.get('HTTP_X_FHOST', '')
if host:
environ['HTTP_HOST'] = host
return self.app(environ, start_response)
FLASK_APP_MUTATOR = lambda app: attach_handler(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment