supabase.auth.getSession returning undefined #19240
Closed
Ashley-small
started this conversation in
Jobs Board
Replies: 1 comment 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am building a website for a local health service. A form of tracker.
The issue is I am trying to get session data so that I can display emails, names and things like that on a specific page in the form of props. Supabase says my dummy user is logged in and I have the local storage cookies, however, supabase.auth.getSession is returning undefined.
This is the layout component
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
import { cookies } from "next/headers";
import Navbar from "./Navbar";
export default async function ProfileLayout({ children }) {
const supabase = createServerComponentClient({ cookies });
const { data } = await supabase.auth.getSession();
console.log(data);
return (
<>
{children}
</>
);
}
This is the Login Page.
"use client";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import AuthForm from "../AuthForm";
import { useState } from "react";
import { useRouter } from "next/navigation";
export default function Login() {
const router = useRouter();
const [error, setError] = useState("");
const handleSubmit = async (e, email, password) => {
e.preventDefault();
setError("");
const supabase = createClientComponentClient();
const { error } = await supabase.auth.signInWithPassword({
email,
password,
});
if (error) {
setError(!error.message);
}
if (!error) {
router.push("/Profile");
}
};
return (
Login
);
}
Beta Was this translation helpful? Give feedback.
All reactions