import { createTRPCReact } from '@trpc/react-query' import { createTRPCClient, httpBatchLink } from '@trpc/client' import type { AppRouter } from '@backend/trpc/router' const BASE_API_URL = 'http://192.168.100.111:8787' export const trpc = createTRPCReact() export function getTrpcClient() { return createTRPCClient({ links: [ httpBatchLink({ url: `${BASE_API_URL}/api/trpc`, headers: async () => { try { const token = localStorage.getItem('auth_token') const headers: Record = { 'caller-interface': 'web', } if (token) { headers.Authorization = `Bearer ${token}` } return headers } catch {} return { 'caller-interface': 'web' } }, }), ], }) }