I’d like to recover my session with the dynamicIO enabled, which allows the use cache to be added. However, I’m facing multiple errors. I’ve tried several solutions based on what the docs suggest, such as adding an auxiliary function (GetSession) with a use cache or caching the page directly, but the errors persist.
When I use await auth directly in my page I get this error: [ Server ] Error: Route “/”: A component has accessed data, headers, parameters, searchParams, or a short-lived cache without a Suspense limit or “use cache” above. We haven’t yet added the exact line number to the error messages, but you can see which component in the stack below.
But when I use the auxiliary function (GetSession) I get a different error: [Cache ] Error: Route / used “headers” inside “use cache”. Access to dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function, use “headers” outside the cached function and pass the required dynamic data as an argument.
page.tsx
import { auth } from "@/auth";
import { GithubLoginForm } from "@/components/auth-form/github-login-form";
// const GetSession = async () => {
// "use cache";
// const session = await auth();
// console.log(session);
// return session;
// };
export default async function Home() {
const session = (await auth());
// const session = await GetSession();
console.log(session);
return (
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
<GithubLoginForm />
</main>
</div>
);
}