Fixes root path bug

This commit is contained in:
Aaron Louie 2020-05-25 11:41:53 -04:00
parent 14a2e4b5fa
commit d1eba27ee0
2 changed files with 10 additions and 3 deletions

View File

@ -18,4 +18,8 @@ if [ "$RESET_DB" = "true" ]; then
pipenv run flask load-example-data
fi
pipenv run gunicorn -e SCRIPT_NAME="$APPLICATION_ROOT" --bind 0.0.0.0:"$PORT0" wsgi:app
if [ "$APPLICATION_ROOT" = "/" ]; then
pipenv run gunicorn -e --bind 0.0.0.0:$PORT0 wsgi:app
else
pipenv run gunicorn -e SCRIPT_NAME="$APPLICATION_ROOT" --bind 0.0.0.0:$PORT0 wsgi:app
fi

View File

@ -8,11 +8,14 @@ if __name__ == "__main__":
def no_app(environ, start_response):
return NotFound()(environ, start_response)
# Remove trailing slash, but add leading slash
base_url = '/' + app.config['APPLICATION_ROOT'].strip('/')
routes = {'/': app.wsgi_app}
app.wsgi_app = DispatcherMiddleware(no_app, {app.config['APPLICATION_ROOT']: app.wsgi_app})
if base_url != '/':
routes[base_url] = app.wsgi_app
app.wsgi_app = DispatcherMiddleware(no_app, routes)
app.wsgi_app = ProxyFix(app.wsgi_app)
flask_port = app.config['FLASK_PORT']