K
Kinde3mo ago
gitgy

Stripe success_url from checkout session logs user out.

const session = await stripeClient.checkout.sessions.create({ success_url: `https://mydomain.com/restoflink and https://mydomain-staging.com/restoflink Hello, when my application gets redirected to the success_url on staging, the user is still logged in (cookies are still set, etc) and correctly redirects to the success_url. However, on my production url, the user is always logged out and redirected to my home page. Here's the code for the specific page I want to redirect to: const {getPermission, getUser} = getKindeServerSession(); const user = await getUser() const isAdmin = await getPermission("xxxx") if (!user) { redirect('/') } const userExists = await db.query.users.findFirst({ where: (fields) => eq(fields.kindeId, user.id) }); if (!userExists) { redirect('/') } const courseExists = await getCourseBySlug(params.course) if (!courseExists) { return <p className="mx-auto text-center font-extrabold mt-40">Course not found</p>; } if (!courseExists.isPublished && !isAdmin?.isGranted) { redirect('/') }
3 Replies
gitgy
gitgyOP3mo ago
NOTE: I tried redirecting to my base url. like 'https://mydomain.com" and it still signs me out.
IkiTg07
IkiTg073mo ago
This is weird. Does it mean the cookies are deleted when you're doing the actions on your prod env ?
gitgy
gitgyOP3mo ago
Yeah, it was deleted. It's odd but when I use an environment variable, it works. const session = await stripeClient.checkout.sessions.create({ success_url: `${process.env.NEXT_PUBLIC_BASE_URL}
Want results from more Discord servers?
Add your server