Skip to content

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

fix: set cache control explicitly (#2088)

Max Deichmann830ebf6fff8c
diff --git a/web/src/pages/api/auth/[...nextauth].ts b/web/src/pages/api/auth/[...nextauth].ts
index 07ac8e5bd5..93df6f12da 100644
--- a/web/src/pages/api/auth/[...nextauth].ts
+++ b/web/src/pages/api/auth/[...nextauth].ts
@@ -5,5 +5,9 @@ import NextAuth from "next-auth";
export default async function auth(req: NextApiRequest, res: NextApiResponse) {
// Do whatever you want here, before the request is passed down to `NextAuth`
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
+ res.setHeader("Cache-Control", "no-store, max-age=0");
return await NextAuth(req, res, authOptions);
}
diff --git a/web/src/server/auth.ts b/web/src/server/auth.ts
index 287ec26944..348cc8ea68 100644
--- a/web/src/server/auth.ts
+++ b/web/src/server/auth.ts
@@ -348,5 +348,9 @@ export const getServerAuthSession = async (ctx: {
res: GetServerSidePropsContext["res"];
}) => {
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");
return getServerSession(ctx.req, ctx.res, authOptions);
};