From 8d48ae0359f74d35503f4bcaa1699d819cd20733 Mon Sep 17 00:00:00 2001 From: Igor Belogurov Date: Thu, 28 Aug 2025 18:44:19 +0200 Subject: [PATCH] fix(orpc): add Next.js server-side headers support (#550) --- .../api/orpc/web/react/base/src/utils/orpc.ts.hbs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs b/apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs index 7d735f5..4060212 100644 --- a/apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +++ b/apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs @@ -33,6 +33,16 @@ export const link = new RPCLink({ credentials: "include", }); }, + {{#if (includes frontend "next")}} + headers: async () => { + if (typeof window !== "undefined") { + return {} + } + + const { headers } = await import("next/headers") + return Object.fromEntries(await headers()) + }, + {{/if}} {{/if}} });