#[CLOSED] NextJS OAuth Inconsistent Redirect Results

11 messages · Page 1 of 1 (latest)

heavy jungle
#

I have just implemented the SSR authentication flow for Next.js.

I have two providers, GitHub and Discord.

With GitHub everything works flawlessly. The user is logged in already on redirect.

With Discord, however, the user object returned from this function is null.

export const getLoggedInUser = cache(async () => {
  try {
    const { account } = await createSessionClient();
    return await account.get();
  } catch (error) {
    return null;
  }
});

I have to refresh the page, and then the user object is retrieved and the user is logged in.

I've looked at the HTTP Request objects in dev tools, and most apparent difference are the referrer policies.
The redirect urls from GitHub are origin-when-cross-origin while the ones from Discord are strict-origin-when-cross-origin.

I have only tested this in a local development environment.

heavy jungle
#

I have the same issue with Google.

heavy jungle
#

Bump

bleak quiver
#

Same issue with Google on SvelteKit

red hamlet
heavy jungle
#

I did. I followed your SSR auth guide for Next.js.

red hamlet
red hamlet
#

After the redirect from the oauth provider and you create the session, can you verify the session works?

red hamlet
heavy jungle
#

I mean, I ended up using the window.open api and refreshed the main page when it closed.

#

But I moved over to Supabase instead, so I don't have the code anymore