withPageAuth, user always undefined
See original GitHub issueUsing supabase v2 and the latest version of all packages.
This example is lifted straight from the documentation. Authenticated users are properly redirected to the login page. On successful authentication, the login page redirects the user back to this page via router.replace(…)
The issue is that the user
variable is always undefined
.
// index.tsx
import { User, withPageAuth } from "@supabase/auth-helpers-nextjs";
type HomePageProps =
{
user: User;
};
export default function HomePage({ user }: HomePageProps)
{
return <div>Hello { user.email }</div>;
}
export const getServerSideProps = withPageAuth({ redirectTo: "/login" });
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
withPageAuth user undefined for authenticated user #203
Issue regarding withPageAuth. I have setup a profile page using withPageAuth and the user data is always undefined in the component.
Read more >supabase auth-helpers-nextjs package not working properly
I am using supabase auth condition in the order page. But when the user enters the login details it is not redirected to...
Read more >'user' is undefined and isAuthenticated returns false after login
I am able to log in and redirect to my redirectURI path but I get an error “Cannot destructure property 'name' of 'user'...
Read more >Authsignal - Supabase
This guide shows how to integrate Authsignal with Next.js and Supabase in order to add an MFA step after sign-in. The user flow...
Read more >helpers/with-page-auth-required | @auth0/nextjs-auth0
WithPageAuthRequired. Wrap your getServerSideProps with this method to make sure the user is authenticated before visiting the page. // pages/protected-page.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for reporting this, and very, sorry this was an unintended regression and has been fixed in v4.0.1: https://github.com/supabase/auth-helpers/blob/main/packages/nextjs/CHANGELOG.md#041
I too get this error, when I do getUser()
Also no sign-in cookies are set in the browser.