pallets-eco / flask-debugtoolbar

A toolbar overlay for debugging Flask applications
https://flask-debugtoolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
953 stars 146 forks source link

No toolbar on either Chrome or firefox #139

Closed johnxpan closed 4 years ago

johnxpan commented 5 years ago

I added the flask debug toolbar to my app. It looks working because it gave me the redirect warning like below:

_Redirect (302) Location: /app/bokeh

The Flask Debug Toolbar has intercepted a redirect to the above URL for debug viewing purposes. You can click the above link to continue with the redirect as normal. If you'd like to disable this feature, you can set the config variable DEBUG_TB_INTERCEPTREDIRECTS to False.

But there is no FDT tool bar shown up after I got the response. I tried both Chrome and Firefox, same result. Do I need to do any configuration on the browser side to display the toolbar?

johnxpan commented 5 years ago

It is related to the dynamic routing of docker container. Does anybody know how to configure the host IP address of docker container to bypass the problem? Thanks!

johnxpan commented 5 years ago

Finally, we found the root cause, our server is a hybrid of both cgi-bin and flask. the invocation url is not "/" but "/app/". The flask debug toolbar by default try to load the toolbar from "https://xyz.com/_debug_toolbar/static/js/toolbar.js",
instead of the correct url: "https://xyz.com/app/_debug_toolbar/static/js/toolbar.js" Is there any configuration parameter we can use to set this correct?

mattaw commented 4 years ago

I don't know if you fixed this, but I run a flask app under a prefix and the proxy supplies the right prefix, and Flask respects it by default so the toolbar works. (There is a bug in the SQLAlchemy EXPLAIN/SELECT sub-panels that I have submitted a pull request for.) You could try setting SCRIPT_NAME in the Flask config if your proxy is not doing it right now?

jeffwidman commented 4 years ago

Just merged @mattaw 's pull request.

@johnxpan what does Flask think it's home url/prefix is? Ie, is the redirect to /app prefix happening within Flask or externally? If external, then you need to fix your proxy to also redirect the javascript files. Otherwise if within Flask, how are you setting that prefix? Is it for the whole app, or just a sub-blueprint?