ITADN

Support for `host_matching`

#269Closedsamuelhwilliams 创建于 2024-06-17
S
samuelhwilliamscommented
It doesn't seem like Flask-DebugToolbar supports running flask in `host_matching` mode. When Flask is configured this way, the URLs generated for Flask-DebugToolbar's assets are invalid, so none of the JS/CSS loads. Here's a minimal app for reproducing: ```python from flask import Flask from flask_debugtoolbar import DebugToolbarExtension app = Flask( __name__, host_matching=True, static_host='sub1.app.localhost:5000', ) app.config['DEBUG_TB_ENABLED'] = True app.config['SECRET_KEY'] = 'abc123' toolbar = DebugToolbarExtension(app) @app.route("/", host='sub1.app.localhost:5000') def sub1_index(): return f"<html><head></head><body>OK</body></html>" ``` Which results in this truncated HTML being injected. Note the `http:///`, which is invalid. ```html <div id="flDebug" style="display:none;" role="navigation"> <script type="text/javascript">var DEBUG_TOOLBAR_STATIC_PATH = 'http:///_debug_toolbar/static/'</script> <script type="text/javascript" src="http:///_debug_toolbar/static/js/jquery.js"></script> <!-- Temporarily adding jquery-migrate during the Jquery upgrade process, this can be removed post-upgrade --> <script src="http:///_debug_toolbar/static/js/jquery-migrate.js"></script> <script type="text/javascript" src="http:///_debug_toolbar/static/js/jquery.tablesorter.js"></script> <script type="text/javascript" src="http:///_debug_toolbar/static/js/toolbar.js"></script> ... ``` I've put together a changeset that I think would address this issue - happy to hear thoughts before raising a PR: https://github.com/pallets-eco/flask-debugtoolbar/compare/main...samuelhwilliams:flask-debugtoolbar:add-host-support?expand=1
关闭于 2024-07-15 6 条评论