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.

Always getting the error "Auth session missing!" when signing in

See original GitHub issue

Hello, I’ve been trying to get supabase auth working on a Nuxt3 project and always get the “Auth session missing!” message from this line: https://github.com/nuxt-community/supabase-module/blob/6d05b9383bd3c9b039e5f7ca17beba8a50812b2a/src/runtime/server/api/session.ts#L17

I was wondering if I had missed something to setup the session? This maybe a beginner issue as I’m just getting into Nuxt3, I’ve not found anything about authentication sessions on the docs.

Thanks for your time, have a great day.

EDIT: It seems I’m getting the error only when I’m coming from a sign up confirmation link not for “normal sign in”.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:21

github_iconTop GitHub Comments

1reaction
mwohlancommented, Apr 22, 2022

I was able to reproduce the “Auth session missing!” error: when multiple tabs of the same app are open with the onAuthStateChange listener active. Only the tab with the active login has a session != null here:

  // Once Nuxt app is mounted
  nuxtApp.hooks.hook('app:mounted', () => {
    // Listen to Supabase auth changes
    client.auth.onAuthStateChange(async (event: AuthChangeEvent, session: Session | null) => {
      await setServerSession(event, session)
      user.value = client.auth.user()
    })
  })
})

The others will throw the error because the session is null, but will get the user anyways, because it has been handled by the active login tab. When no tab besides the active login tab of the same app is open, the error is not thrown.

So maybe simply return here instead of throwing an error ?

if (signEvent === 'SIGNED_IN') {
    if (!session) { throw new Error('Auth session missing!') }
    setCookie(
      event,
      `${cookieOptions.name}-access-token`,
      session.access_token,
      {
        domain: cookieOptions.domain,
        maxAge: cookieOptions.lifetime ?? 0,
        path: cookieOptions.path,
        sameSite: cookieOptions.sameSite
      }
    )
  }

1reaction
larbishcommented, Apr 13, 2022

The tag was available anyway. Just created the release 😀

Read more comments on GitHub >

github_iconTop Results From Across the Web

session() and user() reportedly not returning data on first ...
1. Check on page load whether a user is logged in: This works synchronously as expected. When GoTrue is initialized (which happens when...
Read more >
NextJS and NextAuth session user object getting lost due to ...
Basically I was misunderstanding that I needed to use the jwt callback and on the first call to this callback, the user model...
Read more >
Can't sign in from a third-party service - Google Account Help
An error saying that your password and username are incorrect, even if you've entered the correct information. Note: If you have an account...
Read more >
Troubleshooting Authentication Issues - Microsoft Learn
User fails to authenticate using OTP with the error: "Authentication failed due to an internal error". Error received (client event log).
Read more >
Admin Authentication API Errors | Firebase - Google
The error message should contain the response from the Authentication server ... Enable it from the Sign-in Method section of the Firebase console....
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