Feature/fix reverse proxy (#435)

* new: dev: raise error when used

* chg: dev: add info on error
This commit is contained in:
rachmadani haryono 2020-02-08 20:07:19 +08:00 committed by GitHub
parent 5638226883
commit 5a23be2ab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,10 @@ from flask_admin import Admin
from flask_api import exceptions, FlaskAPI, status
from flask_bootstrap import Bootstrap
from flask_paginate import Pagination, get_page_parameter, get_per_page_parameter
from flask_reverse_proxy_fix.middleware import ReverseProxyPrefixFix
try:
from flask_reverse_proxy_fix.middleware import ReverseProxyPrefixFix
except ModuleNotFoundError:
ReverseProxyPrefixFix = None
from markupsafe import Markup
import click
import flask
@ -236,7 +239,10 @@ def create_app(db_file=None):
if reverse_proxy_path.endswith('/'):
print('Warning: reverse proxy path should not include trailing slash')
app.config['REVERSE_PROXY_PATH'] = reverse_proxy_path
ReverseProxyPrefixFix(app)
if ReverseProxyPrefixFix:
ReverseProxyPrefixFix(app)
else:
raise ModuleNotFoundError('Failed to import ReverseProxyPrefixFix')
bukudb = BukuDb(dbfile=app.config['BUKUSERVER_DB_FILE'])
app.app_context().push()
setattr(flask.g, 'bukudb', bukudb)