After playing around I worked out what the problem is (then discovered someone else already had worked it out too).
The issue is that when you mount the Dash app at /dash
, while the dispatcher is aware of this prefix, the Dash app itself is not. In particular the API requests from the client are still being directed to their various endpoints at the root. For example the failed request that leads to the error you see is going to /_dash-layout
, when it should be going to /dash/_dash-layout
. As suggested in the post I linked to, you can fix this by updating Dash’s request route prefix to make it relative rather than absolute, like this:
app.config.requests_pathname_prefix = ''
This however will break if you provide a custom value of url_base_pathname
when creating a Dash instance. I think a more general solution could be this, however I haven’t tested it all that thoroughly:
app.config.requests_pathname_prefix = app.config.routes_pathname_prefix.split('/')[-1]
Also, I think the reason that Stackoverflow answer you linked to works, is not because it solves this problem, but because it just works around it by having the Dash app’s Flask instance be mounted at the root and therefore does not have to worry about the discrepancy between prefixes. The approach I’ve suggested, is more general, allowing you to mount the Dash instance wherever you want.