From fe50f04075e188c1c119510f95f14c6810486a52 Mon Sep 17 00:00:00 2001 From: zomars Date: Tue, 28 Jun 2022 11:37:01 -0600 Subject: [PATCH] Only stale SSR requests --- apps/web/pages/api/trpc/[trpc].ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/pages/api/trpc/[trpc].ts b/apps/web/pages/api/trpc/[trpc].ts index 1c8d6f7b74..11e64840bd 100644 --- a/apps/web/pages/api/trpc/[trpc].ts +++ b/apps/web/pages/api/trpc/[trpc].ts @@ -37,7 +37,9 @@ export default trpcNext.createNextApiHandler({ // checking we're doing a query request const isQuery = type === "query"; - if (allPublic && allOk && isQuery) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ctx.req is available for SSR but not SSG + if (!!ctx?.req && allPublic && allOk && isQuery) { // cache request for 1 day + revalidate once every 5 seconds const ONE_DAY_IN_SECONDS = 60 * 60 * 24; return {