question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

withPageAuth, user always undefined

See original GitHub issue

Using 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:closed
  • Created a year ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
thorwebdevcommented, Oct 17, 2022

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

2reactions
Shevlycommented, Oct 16, 2022

I too get this error, when I do getUser()

{
  data: { user: null },
  error: AuthApiError: Internal server error
      at C:\Users\Riot\Documents\Project\node_modules\@supabase\gotrue-js\dist\main\lib\fetch.js:41:20
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    __isAuthError: true,
    status: 500
  }
}

Also no sign-in cookies are set in the browser.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found