Can't access the session inside a server action

export const protectedAction = createSafeActionClient({
  async middleware() {
    const session = await getServerAuthSession();

    console.log(session);

    if (!session?.user) {
      throw new Error("Unauthorized!");
    }

    return { session };
  },
});


using NextAuth and next-safe-actions
Was this page helpful?