Skip to content

auth.getUser() returns null despite having a session #22533

Closed Answered by Cainor
Ryurcia asked this question in Questions
Discussion options

You must be logged in to vote

I've solved my issue.

Here is where I tried to be a good programmer without understanding what is going on. First of all I'm using Next.js and following this doc: https://supabase.com/docs/guides/auth/server-side/nextjs

In the "actions.ts" file, I saw that the doc is declaring const supabase = createClient() in every function, and here I thought: "hmm, this is not efficient" so this is what I did:

import { createClient } from "~/utils/supabase/server";

const supabase = createClient();

export async function login(formData: FormData) {
...
}
export async function signup(formData: FormData) {
...
}

This, somehow has the login function working properly except that it never stores cookies.

F…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@Ryurcia
Comment options

Comment options

You must be logged in to vote
4 replies
@Cainor
Comment options

@Cainor
Comment options

Answer selected by Ryurcia
@Ryurcia
Comment options

@Cainor
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants