plotly / dash-labs

Work-in-progress technical previews of potential future Dash features.
MIT License
140 stars 39 forks source link

path fixes for DE #78

Closed chriddyp closed 2 years ago

johnkangw commented 2 years ago

PR (https://github.com/plotly/dash-labs/pull/78) fixed most of the pathing issues (thank you so much!) as the homepage is showing up, but I still have one issue remaining. I have links that reference the various sub-pages on the top of my app and when I click on them they do not do anything (I just stay on the homepage) on Dash Enterprise (works when I run the multi-page app on my local machine).

I can workaround it for now by adding in the app name. So for example:

When clicking on the link on my header I try to go to the link which doesn't work: https://appserver.host/regional

When I manually add in the name of the app ('capacity') to the address bar and press enter on the below link it does work: https://appserver.host/capacity/regional

I believe this is an issue with how the page['path'] is served. I am serving up the page['path'] to a dcc.Link object as the href. I think that needs to have added on it the name of the app when hosted on Dash Enterprise.

ddk.Menu( children=[dcc.Link(page["name"], href=page["path"]) for page in dash.page_registry.values() if (not page["path"].startswith("/chapter")) and (page["path"].find("404") == -1)], )

I checked the server logs and the error I receive is below (similar to the one from before): 2022-01-27T08:29:55.407037545Z app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1336, in dispatch 2022-01-27T08:29:55.407040645Z app[web.1]: response.set_data(func(args, outputs_list=outputs_list)) 2022-01-27T08:29:55.407044045Z app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/_callback.py", line 151, in add_context 2022-01-27T08:29:55.407047145Z app[web.1]: output_value = func(func_args, **func_kwargs) # %% callback invoked %% 2022-01-27T08:29:55.407049945Z app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash_labs/plugins/pages.py", line 335, in update 2022-01-27T08:29:55.407052945Z app[web.1]: page, path_variables = _path_to_page(app, app.strip_relative_path(pathname)) 2022-01-27T08:29:55.407055845Z app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1562, in strip_relative_path 2022-01-27T08:29:55.407058845Z app[web.1]: return strip_relative_path(self.config.requests_pathname_prefix, path) 2022-01-27T08:29:55.407061645Z app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/_utils.py", line 85, in strip_relative_path 2022-01-27T08:29:55.407064545Z app[web.1]: raise exceptions.UnsupportedRelativePath( 2022-01-27T08:29:55.407067345Z app[web.1]: dash.exceptions.UnsupportedRelativePath: Paths that aren't prefixed with requests_pathname_prefix are not supported. 2022-01-27T08:29:55.407070145Z app[web.1]: You supplied: /regional and requests_pathname_prefix was /capacity/