Xirynx
Xirynx
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
I can see from your code snippet that you changed the default cookie prefix, is that maybe affecting the ability of the auth client to pick up the cookie?
142 replies
BABetter Auth
Created by Felix on 4/10/2025 in #help
Session cookie not working in production deployment
No description
142 replies
BABetter Auth
Created by Xirynx on 4/4/2025 in #help
Authentication with Express backend + Next.js frontend
Thank you @Ali Nasir @Ping
8 replies
BABetter Auth
Created by Xirynx on 4/4/2025 in #help
Authentication with Express backend + Next.js frontend
I tried this as a quick test, and it seems to work. Wondering if this is a valid approach?
import { SignOutButton } from '@/components/sign-out-button';
import { authClient } from '@/lib/auth';
import { headers } from "next/headers";

export default async function Locked() {
const { data, error } = await authClient.getSession({
fetchOptions: {
headers: await headers(),
}
});

if (error) {
// handle error
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Error</h1>
<p className="text-lg mb-4">{error.message}</p>
</div>
);
}

if (!data) {
// handle error
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Error</h1>
<p className="text-lg mb-4">You are not logged in</p>
</div>
);
}

return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">This is a protected page</h1>
<p className="text-lg mb-4">You are logged in as {data.user.name}</p>
<SignOutButton />
</div>
);
}
import { SignOutButton } from '@/components/sign-out-button';
import { authClient } from '@/lib/auth';
import { headers } from "next/headers";

export default async function Locked() {
const { data, error } = await authClient.getSession({
fetchOptions: {
headers: await headers(),
}
});

if (error) {
// handle error
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Error</h1>
<p className="text-lg mb-4">{error.message}</p>
</div>
);
}

if (!data) {
// handle error
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Error</h1>
<p className="text-lg mb-4">You are not logged in</p>
</div>
);
}

return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">This is a protected page</h1>
<p className="text-lg mb-4">You are logged in as {data.user.name}</p>
<SignOutButton />
</div>
);
}
8 replies