# Error encountered when pressing back button

**URL:** <https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782>\
**Category:** Get Help\
**Created:** [June 23, 2022, 7:55am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782 "2022-06-23T07:55:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev40](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dev40/32/33281_2.png) [@dev40](https://community.auth0.com/u/dev40)\
**Post date:** [June 23, 2022, 7:55am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/1 "2022-06-23T07:55:22Z")

</div>

How can I solve this issue when pressing the back button?  
Steps:

1. login using google account, and pretend to login incorrect account
2. Unauthorized page will display
3. click the back button of the browser and login the correct account

 ![1](https://global.discourse-cdn.com/auth0/original/3X/6/c/6ce88e409f466c2c0f0d6fefea75ed5a66a12c49.png)

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 23, 2022, 10:17pm UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/3 "2022-06-23T22:17:43Z")

</div>

Hi @dev40,

Thanks for reaching out to the Auth0 Community!

I understand that you encountered a situation where clicking the back button led to an error page.

This happens when the login transaction no longer exists after pressing the back button.

In this situation, I suggest configuring a Default Login Route for your application by going to your [Auth0 Dashboard \> Settings \> Advanced](https://manage.auth0.com/#/tenant/advanced) settings and including your Login URI. Please do not forget to save your changes.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/e/aec11a64ef11114ebe8e1821f7459867e026e0a5.png)

Once that is complete, your users should be able to return to the login page when pressing the back button.

See our [Configure Default Login Routes](https://auth0.com/docs/authenticate/login/auth0-universal-login/configure-default-login-routes) documentation to learn more.

Please let me know if there’s anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![dev40](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dev40/32/33281_2.png) [@dev40](https://community.auth0.com/u/dev40)\
**Post date:** [June 24, 2022, 12:18am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/4 "2022-06-24T00:18:57Z")

</div>

Hi @rueben.tiow , I already defined a URL but it is still happening. Is there any other solution?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 24, 2022, 4:26pm UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/5 "2022-06-24T16:26:35Z")

</div>

Hi @dev40,

Thank you for your response.

I have not been able to reproduce your observations. Instead, I was able to press the back button and redirect my user to the default login page.

With that, could you please share the URL you defined?

Please make sure to hide any sensitive information.

Thank you.

---

<div class="post-metadata">

**Author:** ![dev40](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dev40/32/33281_2.png) [@dev40](https://community.auth0.com/u/dev40)\
**Post date:** [June 27, 2022, 12:04am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/6 "2022-06-27T00:04:34Z")

</div>

@rueben.tiow I tried [https://hub-test.myapp.co.nz/haven/login](https://hub-test.myapp.co.nz/haven/login) and it is not working.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/0/d/0d1d8d8f524115de58516ce2911789057b0a93b6.png)

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 28, 2022, 5:19pm UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/7 "2022-06-28T17:19:17Z")

</div>

Hi @dev40,

Thank you for your reply.

I have inspected your default login URL and noticed that the URL may need to point to the `login` route to redirect the users back to the `authorize` endpoint (login page).

Given that, could you please try saving your default login route with `/login` and see how that works?  
(e.x `https://hub-test.myapp.co.nz/haven/login`)

Please let me know how this works for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![dev40](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dev40/32/33281_2.png) [@dev40](https://community.auth0.com/u/dev40)\
**Post date:** [June 30, 2022, 8:31am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/8 "2022-06-30T08:31:09Z")

</div>

@rueben.tiow I tried [https://hub-test.myapp.co.nz/haven/login](https://hub-test.myapp.co.nz/haven/login) but it is still not working ☹

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 30, 2022, 4:52pm UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/9 "2022-06-30T16:52:00Z")

</div>

Hi @dev40,

Thank you for your update.

> [@dev40](#):
>
> it is still not working ☹

There is one final recommendation I could offer, which is to directly set the `/authorize` endpoint as your default login URI.

The default login URI pointing to your `/authorize` endpoint would look something like the following:

```auto
https://YOUR_DOMAIN/authorize?
    response_type=code&
    client_id=YOUR_CLIENT_ID&
    redirect_uri=https://YOUR_APP/callback&
    scope=SCOPE&
    state=STATE

```

This way, whenever a user presses the back button, they are immediately directed to your application’s login page.

Please let me know how this works for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![appurist](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/appurist/32/38507_2.png) [@appurist](https://community.auth0.com/u/appurist)\
**Post date:** [June 30, 2022, 6:42pm UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/10 "2022-06-30T18:42:35Z")

</div>

I resolve this type of issue with people pressing the Back button by clearing the browser state (for the Back button) once they’ve reached my page with something like:

```auto
window.history.replaceState({}, "", window.location.origin + "/");

```

or where ever you’d prefer them to end up on a Back operation. If you want it to just stay where you are, you can of course use:

```auto
window.history.replaceState({}, "", window.location.origin + window.location.pathname);

```

See the documentation for [window.history](https://developer.mozilla.org/en-US/docs/Web/API/History) and in particular the state-related calls, and [window.location](https://developer.mozilla.org/en-US/docs/Web/API/Location).

---

<div class="post-metadata">

**Author:** ![dev40](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dev40/32/33281_2.png) [@dev40](https://community.auth0.com/u/dev40)\
**Post date:** [July 1, 2022, 2:03am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/11 "2022-07-01T02:03:24Z")

</div>

@rueben.tiow in the Tenant and Application settings located in the dashboard, it does not accept this format. It response ““Tenant Login URI” must be a valid uri with a scheme matching the https pattern”

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 5, 2022, 4:18pm UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/12 "2022-07-05T16:18:06Z")

</div>

Hi @dev40,

Thank you for your reply.

> [@dev40](#):
>
> it does not accept this format. It response ““Tenant Login URI” must be a valid uri with a scheme matching the https pattern”

I have tested your observations and could reproduce the same message only when passing a `http` URL.

Seeing that, could you please double check that your default login URI points to a `https` URL?

If you continue to have errors, could you please screenshot your tenant setting page with the error? And could you also please share the complete URL you are using?

Thank you.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 22, 2022, 9:32am UTC](https://community.auth0.com/t/error-encountered-when-pressing-back-button/85782/13 "2022-12-22T09:32:09Z")

</div>


