KindeK
Kinde2y ago
Ajinkya

Remix app how to redirect to previous page post login

in my remix js app I have http://localhost:9001/app behind auth.
So when users lands at http://localhost:9001/app/xyz it successfully goes to login page if users is not authenticated, but after login user is being redirected to homepage http://localhost:9001/ I would like to change that. Please guide me.🐮

My loader at the moment withing /app.tsx

// app.tsx
export const loader = async ({request}: LoaderFunctionArgs) => {
  const {getUser} = await getKindeSession(request);
  const user = await getUser();

  if (user === null) {
    throw redirect("/kinde-auth/login?returnTo=/");
  }

  return json({user});
};


if any pages loads at /app/new it is automatically behind auth.

KINDE_SITE_URL=http://localhost:9001
KINDE_POST_LOGOUT_REDIRECT_URL=http://localhost:9001/logout
KINDE_POST_LOGIN_REDIRECT_URL=http://localhost:9001/app
Was this page helpful?