Server Action With getServerSession

hi i am trying to use getServerSession from server action it giving me error in terminal
error Error: Invariant: Method expects to have requestAsyncStorage, none available
at BuyProSubscription (pricing/buyNowAction.ts:15:86)
error Error: Invariant: Method expects to have requestAsyncStorage, none available
at BuyProSubscription (pricing/buyNowAction.ts:15:86)
in console(frontend)
Uncaught (in promise) Error: Invariant: Method expects to have requestAsyncStorage, none available
at headers (C:\Users\new\Documents\striver-sheet-website\node_modules\.pnpm\next@13.4.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\client\components\headers.js:40:15)
at getServerSession (C:\Users\new\Documents\striver-sheet-website\node_modules\.pnpm\next-auth@4.22.1_next@13.4.1_nodemailer@6.9.2_react-dom@18.2.0_react@18.2.0\node_modules\next-auth\next\index.js:144:35)
Uncaught (in promise) Error: Invariant: Method expects to have requestAsyncStorage, none available
at headers (C:\Users\new\Documents\striver-sheet-website\node_modules\.pnpm\next@13.4.1_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\client\components\headers.js:40:15)
at getServerSession (C:\Users\new\Documents\striver-sheet-website\node_modules\.pnpm\next-auth@4.22.1_next@13.4.1_nodemailer@6.9.2_react-dom@18.2.0_react@18.2.0\node_modules\next-auth\next\index.js:144:35)
code
"use server";

import { authOption } from "@/lib/auth";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
import { absoluteUrl } from "@/lib/utils";
export async function BuyProSubscription() {
const LoginURL = absoluteUrl("register-or-login?callback=%2Fpricing");
const session = await getServerSession(authOption);
console.log(session);
}
"use server";

import { authOption } from "@/lib/auth";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
import { absoluteUrl } from "@/lib/utils";
export async function BuyProSubscription() {
const LoginURL = absoluteUrl("register-or-login?callback=%2Fpricing");
const session = await getServerSession(authOption);
console.log(session);
}
can anyone tell me how can i resolve this issue?
0 Replies
No replies yetBe the first to reply to this messageJoin