Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(auth): extend no-cache headers on server side auth apis (#2856)

Marc Klingenaf0e57e561d8
diff --git a/web/src/server/auth.ts b/web/src/server/auth.ts
index d407d71a5e..db52d94ebc 100644
--- a/web/src/server/auth.ts
+++ b/web/src/server/auth.ts
@@ -487,7 +487,14 @@ export const getServerAuthSession = async (ctx: {
const authOptions = await getAuthOptions();
// https://github.com/nextauthjs/next-auth/issues/2408#issuecomment-1382629234
// for api routes, we need to call the headers in the api route itself
- // disable caching for anything auth related
- ctx.res.setHeader("Cache-Control", "no-store, max-age=0");
+
+ // disable caching for any api requiring server-side auth
+ ctx.res.setHeader(
+ "Cache-Control",
+ "no-store, no-cache, must-revalidate, proxy-revalidate",
+ );
+ ctx.res.setHeader("Pragma", "no-cache");
+ ctx.res.setHeader("Expires", "0");
+
return getServerSession(ctx.req, ctx.res, authOptions);
};