# Default url customising

**URL:** <https://discourse.jupyter.org/t/default-url-customising/11838>\
**Category:** JupyterHub\
**Created:** [November 24, 2021, 3:45pm UTC](https://discourse.jupyter.org/t/default-url-customising/11838 "2021-11-24T15:45:29Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)\
**Post date:** [January 19, 2024, 10:44am UTC](https://discourse.jupyter.org/t/default-url-customising/11838/9 "2024-01-19T10:44:06Z")

</div>

`default_url` will get the user if the request is authenticated. If you aren’t seeing that, my guess is that it’s because default\_url is being called before the user is authenticated, and is being _persisted_ through login, redirects via the `?next` url parameter, so the value doesn’t get recomputed after authentication has completed.

Try sending unauthenticated users directly to /hub/login, which will result in computing default\_url again after successful login, for example:

```python
def default_url(handler):
    user = handler.current_user
    if not user:
        # not logged in, send to login, no ?next
        # that way, default_url will be called again after successful login
        return handler.get_login_url()
    if "admin-ui" in handler.expanded_scopes:
        # has permission to view the admin page, send there
        return handler.base_url + "hub/admin"
    else:
        # regular user, send to spawn page
        # (which redirects to running user if it's running)
        # this is the default default URL
        return handler.base_url + "hub/spawn"

c.JupyterHub.default_url = default_url

```

[complete example jupyterhub\_config.py](https://gist.github.com/minrk/f0edc56bd55cf5c4706658cc15e0883c)

---

_[View the full topic](https://discourse.jupyter.org/t/default-url-customising/11838)._
