How to get the session (next-auth) in server actions???
Answered
Brewer's Blackbird posted this in #help-forum
Brewer's BlackbirdOP
"use server";
...
export const someAction = async () => {
const session = await getServerAuthSession();
console.log("Action session: ", session);
};Output: Action session: null
Answered by Brewer's Blackbird
Is it because of the fact that uploadthing is running not on my website and when I try to get the cookies, it just returns null
4 Replies
If you're using v5, just call await auth()
Brewer's BlackbirdOP
Look, when I call the action inside of the react component, the session is not null.
When I call the action from the Uploadthing router the session is null
When I call the action from the Uploadthing router the session is null
Brewer's BlackbirdOP
Is it because of the fact that uploadthing is running not on my website and when I try to get the cookies, it just returns null
Answer
Brewer's BlackbirdOP
Yeah, I think it pretty much because of it