Ajinkya
Ajinkya
KKinde
Created by Ajinkya on 7/6/2024 in #💻┃support
Remix app how to redirect to previous page post login
As my repo is private
8 replies
KKinde
Created by Ajinkya on 7/6/2024 in #💻┃support
Remix app how to redirect to previous page post login
Raise bug as in on kinde auth GitHub repo ? Please let me know do you need anything apart from this.
8 replies
KKinde
Created by Ajinkya on 7/6/2024 in #💻┃support
Remix app how to redirect to previous page post login
Also I have exact same env file which was shared in Kinde auth setup page for the remix engine.
8 replies
KKinde
Created by Ajinkya on 7/6/2024 in #💻┃support
Remix app how to redirect to previous page post login
I have kinde auth file as given in kinde docs wrt to Remix SDK. app/routes/kinde-auth.$index.tsx And in app/routes/ap.tsx I have the following code:
export const loader = async ({request}: LoaderFunctionArgs) => {
const user = await await requireLoggedInUser(request)
...

#utils.server.ts
import {getKindeSession} from "@kinde-oss/kinde-remix-sdk";
import {redirect} from "@remix-run/node";

export const requireLoggedInUser = async (request: Request): Promise<import("@kinde-oss/kinde-typescript-sdk").UserType> => {
const {getUser} = await getKindeSession(request);
const user = await getUser();
if (user === null) {
throw redirect("/kinde-auth/login?returnTo=/");
}

return user
}
export const loader = async ({request}: LoaderFunctionArgs) => {
const user = await await requireLoggedInUser(request)
...

#utils.server.ts
import {getKindeSession} from "@kinde-oss/kinde-remix-sdk";
import {redirect} from "@remix-run/node";

export const requireLoggedInUser = async (request: Request): Promise<import("@kinde-oss/kinde-typescript-sdk").UserType> => {
const {getUser} = await getKindeSession(request);
const user = await getUser();
if (user === null) {
throw redirect("/kinde-auth/login?returnTo=/");
}

return user
}
8 replies
KKinde
Created by Ajinkya on 7/6/2024 in #💻┃support
Remix app how to redirect to previous page post login
Yes . At the moment if I login the page redirects back to localhost. Even if it redirects to /app that's is also great.
8 replies