Hello,
I recently deployed a multi-page dash app on a Posit Connect Server. When the app launches on Posit Connect server, it only shows the buttons for the pages in the app and doesn’t load the home page and throws the following exception.
dash.exceptions.UnsupportedRelativePath: Paths that aren't prefixed with requests_pathname_prefix are not supported. You supplied: /vanity_url/ and requests_pathname_prefix was /content/{GUID}/
The home page only loads up when the Home
button is clicked. This is how page buttons and links are defined in app.py
file:
# Page buttons and links
dbc.Row([
dbc.Col(
children=[dcc.Link(page['name'], href=page["relative_path"], className="button")],
align="center", style={"font-size":"36px"}
) for page in dash.page_registry.values()
], justify="end")
The home page is registered as follows:
dash.register_page(
__name__,
name = 'Home',
path='/',
order=0
)
As per the Posit Documentation at: Posit Connect Documentation Version 2024.05.0 - Dash
Content URL paths for multi-page Dash apps do not update based on a set vanity URL. For example, setting your application vanity URL to /multi-page-dash/ makes the index page available at that location, but /multi-page-dash/page-2 will not be accessible. page-2 is only accessible via the base content URL, .../content/{GUID}/page-2.
Do not pass the url_base_pathname parameter to the Dash application constructor in your code. Connect sets the base path to the correct location for the deployed application.
The vanity_url
is passed via the posit gui
when the app is initially deployed. So, based on the above documentation, the index page should be served at the/vanity_url/
but it isn’t happening so.
So, how can I make sure the home page loads up when the user navigates to the location https://posit-connect-server/vanity_url/
? For user navigating to other pages, I do not have a problem with the url changing to https://posit-connect-server/content/{GUID}/page-name/
.