diff --git a/app/api/edgestore/[...edgestore]/route.ts b/app/api/edgestore/[...edgestore]/route.ts index 44c590c..439cace 100644 --- a/app/api/edgestore/[...edgestore]/route.ts +++ b/app/api/edgestore/[...edgestore]/route.ts @@ -1,6 +1,5 @@ import { initEdgeStore } from "@edgestore/server"; import { createEdgeStoreNextHandler } from "@edgestore/server/adapters/next/app"; -import { EdgeStoreProvider } from "@edgestore/server/providers/edgestore"; const es = initEdgeStore.create(); @@ -13,14 +12,8 @@ const edgeStoreRouter = es.router({ const handler = createEdgeStoreNextHandler({ router: edgeStoreRouter, - provider: EdgeStoreProvider({ - accessKey: process.env.EDGE_STORE_ACCESS_KEY || "", - secretKey: process.env.EDGE_STORE_SECRET_KEY || "", - }), // this is the default provider and can be omitted }); -export const dynamic = "force-dynamic"; - export { handler as GET, handler as POST }; /** diff --git a/app/panel/settings/account.tsx b/app/panel/settings/account.tsx index f68a082..904dc23 100644 --- a/app/panel/settings/account.tsx +++ b/app/panel/settings/account.tsx @@ -8,6 +8,7 @@ import { toast } from "react-toastify"; import { useEdgeStore } from "@/lib/edgestore"; import clsx from "clsx"; import { Loader2 } from "lucide-react"; +import dynamic from "next/dynamic"; async function handleUserChange( e: FormData, @@ -79,7 +80,7 @@ async function handleUserChange( type Props = {}; -function Account({}: Props) { +function NoSSRAccount({}: Props) { const { edgestore } = useEdgeStore(); const { data: session } = useSession(); const userAvatar = session?.user?.avatar!; @@ -346,4 +347,8 @@ function Account({}: Props) { ); } +const Account = dynamic(() => Promise.resolve(NoSSRAccount), { + ssr: false, +}); + export default Account; diff --git a/lib/edgestore.ts b/lib/edgestore.ts index e712e27..b325fba 100644 --- a/lib/edgestore.ts +++ b/lib/edgestore.ts @@ -1,8 +1,9 @@ "use client"; -// import { type EdgeStoreRouter } from "@/app/api/edgestore/[...edgestore]/route"; +import { type EdgeStoreRouter } from "@/app/api/edgestore/[...edgestore]/route"; import { createEdgeStoreProvider } from "@edgestore/react"; -const { EdgeStoreProvider, useEdgeStore } = createEdgeStoreProvider(); +const { EdgeStoreProvider, useEdgeStore } = + createEdgeStoreProvider(); export { EdgeStoreProvider, useEdgeStore };