Page doesn't get reloaded on a Location pathname change

A callback that handles Location looks as follow:
layout

    dash_app.layout = html.Div([
        dcc.Location(id='location', refresh=True),
        dbc.Nav(
            [
                dbc.NavItem(
                    dbc.NavLink(html.I(className="bi bi-box-arrow-right text-dark"),
                                id='logout-link',
                                href='/auth/logout'
                    ),

                )
            ],
            pills=True,
        ),
        page_container
    ])

callback

    @dash_app.callback(Output('location', 'pathname'),
                       Input('logout-link', 'n_clicks'),
                       State('logout-link', 'href'),
                       prevent_initial_call=True)
    def handle_logout(n_clicks, href):
        return href

When i click the component logout-link the location in an address bar gets actually changed, BUT page doesn’t get reloaded and this is wierd as before i’ve tried the same approach in different callbacks and it worked well when i simply return a new pathname

Hello @kvdm.dev,

It looks like your are returning to the pathname instead of the url.

Not sure if that will fix it or not.

You could also take a look at my logout flow from Flask_Login flow. I use a redirect in logout that redirects to login after 3 second.

You are a bit incorret, href property has to be returned. Thx anyway :+1: , pathname is not what reloads a page.
@dash_app.callback(Output('location', 'pathname'), => @dash_app.callback(Output('location', 'href'),

About 3 seconds. To be honest, it looks as a workaround, when a user is clicking logout one obviously expects to be logged out immidiately.

Hello @kvdm.dev,

You changed from pathname to href? Is that correct, I believe that I recommended changing it from pathname…

Glad you got it working.

If you take a look here you can see how I perform the redirect, I return the pathname as ‘/login’ to the pathname element:

Yes, in the post above you can see two code lines
before

@dash_app.callback(Output('location', 'pathname')

after

@dash_app.callback(Output('location', 'href'),

U said in the first reply “instead of the url” and i’ve got it literally as the property Location.url which doesnt exist, that’s why i found it incorrect.

Another thing you can do is, external_link=True, this will trigger the page to refresh, which should then log the user out.

With dcc.Link, this is refresh=True.