Skip to content

Commit 02a8dbd

Browse files
committed
Add werkzeug ProxyFix X-Forwarded-Prefix support
The base url is not the same as the blueprint mount point because the blueprint url is relative to the application context root. So either the jinja template needs to be altered to use relative urls, or the base_url should be determined per request. This commit changes the base_url to url_for(".show"), this makes the UI work for both proxied and direct requests.
1 parent 32b8554 commit 02a8dbd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

flask_swagger_ui/flask_swagger_ui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import json
3-
from flask import Blueprint, send_from_directory, render_template, request
3+
from flask import Blueprint, send_from_directory, render_template, request, url_for
44

55

66
def get_swaggerui_blueprint(
@@ -49,7 +49,7 @@ def show(path=None):
4949
}
5050
)
5151
fields["config_json"] = json.dumps(default_config)
52-
return render_template("index.template.html", **fields)
52+
return render_template("index.template.html", **{**fields, 'base_url': url_for(".show")})
5353
else:
5454
return send_from_directory(
5555
# A bit of a hack to not pollute the default /static path with our files.

0 commit comments

Comments
 (0)