handleLoginRedirect not redirecting correctly

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') {
        responseType: 'id_token',
      .then((res) => {
        const { tokens } = res;

      .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 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.

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

My app homepage.

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

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