# handleLoginRedirect not redirecting correctly

**URL:** <https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324>\
**Category:** Questions\
**Created:** [March 12, 2021, 5:36pm UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324 "2021-03-12T17:36:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msch92](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/msch92/32/2519_2.png) [@msch92](https://devforum.okta.com/u/msch92)\
**Post date:** [March 12, 2021, 5:36pm UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324/1 "2021-03-12T17:36:22Z")

</div>

I have the following setup for my app:

```
const oktaAuth = new OktaAuth({
    issuer: 'xxx', // hidden
    clientId: 'xxx',
    redirectUri: '/dashboard',
})

```

And for signing in, I have the following:

```
oktaAuth.signInWithCredentials({ username, password })
.then((res) => {
  const { sessionToken } = res;
  if (res.status === 'SUCCESS') {
    oktaAuth.token.getWithoutPrompt({
        responseType: 'id_token',
        sessionToken,
      })
      .then((res) => {
        const { tokens } = res;
        oktaAuth.tokenManager.setTokens(tokens);
        oktaAuth.handleLoginRedirect(tokens);

      })
      .catch((err) => {
          console.log('err', err)
      });
  }
})
.catch((err) => console.log('Found an error', err));

```

However after login, I am redirected to the homepage instead of the desired url. I have added e.g. [https://my-domain.com/dashboard](https://my-domain.com/dashboard) as login redirect URI, and I’ve tried setting the redirectUri in oktaAuth as

`redirectUri: window.location.origin + DASHBOARD`

as well as using `history.push('/dashboard')` with react-router instead. both don’t seem to work.

---

<div class="post-metadata">

**Author:** ![erin.p](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@erin.p](https://devforum.okta.com/u/erin.p)\
**Post date:** [March 12, 2021, 6:11pm UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324/2 "2021-03-12T18:11:08Z")

</div>

Are you being redirected to the Okta homepage or your app homepage?

---

<div class="post-metadata">

**Author:** ![msch92](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/msch92/32/2519_2.png) [@msch92](https://devforum.okta.com/u/msch92)\
**Post date:** [March 13, 2021, 3:20pm UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324/3 "2021-03-13T15:20:30Z")

</div>

My app homepage.

This also doesn’t seem to happen all the time now - just sometimes

---

<div class="post-metadata">

**Author:** ![msch92](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/msch92/32/2519_2.png) [@msch92](https://devforum.okta.com/u/msch92)\
**Post date:** [March 15, 2021, 7:33pm UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324/4 "2021-03-15T19:33:43Z")

</div>

the homepage’s route is just “/”, to clarify

---

<div class="post-metadata">

**Author:** ![roma.rathi](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@roma.rathi](https://devforum.okta.com/u/roma.rathi)\
**Post date:** [June 10, 2022, 3:48am UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324/5 "2022-06-10T03:48:51Z")

</div>

Have you resolved this issue?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 12, 2024, 7:54pm UTC](https://devforum.okta.com/t/handleloginredirect-not-redirecting-correctly/13324/6 "2024-02-12T19:54:16Z")

</div>

Closed on February 12, 2024, 7:54pm UTC


