aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web/lib/trpc.tsx
blob: 540c6ab559e2644aa5a919c8b3585440adc057ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"use client";
import { httpBatchLink } from "@trpc/client";
import type { AppRouter } from "@/server/api/routers/_app";

import { loggerLink } from "@trpc/client";
import { createTRPCClient } from "@trpc/client";

export const api = createTRPCClient<AppRouter>({
  links: [
    loggerLink({
      enabled: (op) =>
        process.env.NODE_ENV === "development" ||
        (op.direction === "down" && op.result instanceof Error),
    }),
    httpBatchLink({
      // TODO: Change this to be a full URL exposed as a client side setting
      url: `/api/trpc`,
    }),
  ],
});