# Angular app non stop refresh after login with code and state query string

**URL:** <https://community.auth0.com/t/angular-app-non-stop-refresh-after-login-with-code-and-state-query-string/106711>\
**Category:** Get Help\
**Tags:** login-prompt-new-experience, login-experience\
**Created:** [May 11, 2023, 7:12am UTC](https://community.auth0.com/t/angular-app-non-stop-refresh-after-login-with-code-and-state-query-string/106711 "2023-05-11T07:12:44Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![frederik.prijck](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/frederik.prijck/32/27014_2.png) [@frederik.prijck](https://community.auth0.com/u/frederik.prijck)\
**Post date:** [May 11, 2023, 9:16am UTC](https://community.auth0.com/t/angular-app-non-stop-refresh-after-login-with-code-and-state-query-string/106711/4 "2023-05-11T09:16:42Z")

</div>

Yes, you need to configure the SDK as follows:

- set the `authorizationParams.redirect_uri` to a unprotected route, e.g. `window.location.origin + '/callback'`
- ensure the router has a route configured for `callback` that does not require authentication
- call loginWithRedirect and configure `appState.target` to be `/`, this ensures our SDK redirects back to the home page after the user was authenticated succesful.

The important part is, as mentioned, to redirect back to an unprotected route that does not call loginWithRedirect.

On top of that, you should not call loginWithRedirect when the user is already authenticated.

Even better would be to use our AuthGuard to protect the home URL, but you still need the `/callback` redirect\_uri part.

---

_[View the full topic](https://community.auth0.com/t/angular-app-non-stop-refresh-after-login-with-code-and-state-query-string/106711)._
