Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

⚡️ Cache auth request (#1618)

Luke Vella8f7aadb685a1
diff --git a/apps/web/src/next-auth.ts b/apps/web/src/next-auth.ts
index bf53a5042..89f267404 100644
--- a/apps/web/src/next-auth.ts
+++ b/apps/web/src/next-auth.ts
@@ -3,6 +3,7 @@ import { posthog } from "@rallly/posthog/server";
import { redirect } from "next/navigation";
import NextAuth from "next-auth";
import type { Provider } from "next-auth/providers";
+import { cache } from "react";
import z from "zod";
import { CustomPrismaAdapter } from "./auth/adapters/prisma";
@@ -193,14 +194,14 @@ const {
},
});
-const auth = async () => {
+const auth = cache(async () => {
const session = await originalAuth();
if (session) {
return session;
}
return getLegacySession();
-};
+});
const requireUser = async () => {
const session = await auth();