level-up/frontend/trpc.ts
Moritz Ruth b431d4098e
All checks were successful
Build / build (push) Successful in 1m10s
Fix trpc URL
2025-03-03 00:47:13 +01:00

19 lines
510 B
TypeScript

import { createTRPCProxyClient, createWSClient, wsLink } from "@trpc/client"
import superjson from "superjson"
import type { AppRouter } from "../backend"
const wsUrl = new URL(location.href)
wsUrl.protocol = wsUrl.protocol.replace("http", "ws")
wsUrl.pathname = "/ws"
wsUrl.hash = ""
export const trpcClient = createTRPCProxyClient<AppRouter>({
links: [
wsLink({
client: createWSClient({
url: wsUrl.href
})
})
],
transformer: superjson
})