From 0e0b2544fdc6a9ff6a59f0e5861b83e78ec255cc Mon Sep 17 00:00:00 2001 From: cooder Date: Wed, 28 Feb 2024 21:34:38 +0800 Subject: [PATCH] fix: NEXT_PUBLIC_SERVER_ORIGIN_URL error --- apps/web/app/trpc-provider.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/web/app/trpc-provider.tsx b/apps/web/app/trpc-provider.tsx index ad3b1fb..7fd4b29 100644 --- a/apps/web/app/trpc-provider.tsx +++ b/apps/web/app/trpc-provider.tsx @@ -14,14 +14,7 @@ import { toast } from 'sonner'; import { useRouter } from 'next/navigation'; import { setAuthCode } from './utils'; -const NEXT_PUBLIC_SERVER_ORIGIN_URL = process.env.NEXT_PUBLIC_SERVER_ORIGIN_URL; - -if ( - NEXT_PUBLIC_SERVER_ORIGIN_URL === undefined || - NEXT_PUBLIC_SERVER_ORIGIN_URL === '' -) { - throw new Error('app-err: NEXT_PUBLIC_SERVER_ORIGIN_URL is not defined!'); -} +const serverOriginUrl = process.env.NEXT_PUBLIC_SERVER_ORIGIN_URL; export function isTRPCClientError( cause: unknown, @@ -98,7 +91,7 @@ export const TrpcProvider: React.FC<{ children: React.ReactNode }> = ({ enabled: () => true, }), httpBatchLink({ - url: NEXT_PUBLIC_SERVER_ORIGIN_URL + '/trpc', + url: serverOriginUrl + '/trpc', async headers() { const token = localStorage.getItem('authCode') || '';