mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-30 07:46:15 +00:00
18 lines
481 B
TypeScript
18 lines
481 B
TypeScript
import { createTRPCClient, httpBatchLink } from '@trpc/client';
|
|
import type { AppRouter } from '@zero/server/trpc';
|
|
import { env } from 'cloudflare:workers';
|
|
import superjson from 'superjson';
|
|
|
|
const getUrl = () => env.VITE_PUBLIC_BACKEND_URL + '/api/trpc';
|
|
|
|
export const getServerTrpc = (req: Request) =>
|
|
createTRPCClient<AppRouter>({
|
|
links: [
|
|
httpBatchLink({
|
|
url: getUrl(),
|
|
transformer: superjson,
|
|
headers: req.headers,
|
|
}),
|
|
],
|
|
});
|