Something went wrong. Try again.
A self-hosted web platform for applications & services with design based on Google's Material 3 Expressive. (Work In Progress)
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637import { createTRPCClient, httpBatchLink, httpLink, httpSubscriptionLink, isNonJsonSerializable, splitLink } from "@trpc/client";import type { TRPCRouter } from "../../backend/index";
const ENDPOINT_URL = `${window.location.origin}/api/app/uk.ewsgit.files`;
const trpc = createTRPCClient<TRPCRouter>({ links: [ splitLink({ condition: (op) => isNonJsonSerializable(op.input), true: httpLink({ url: ENDPOINT_URL, fetch(input, init) { return fetch(input, { credentials: "include", ...init }); }, }), false: splitLink({ condition: (op: { type: string }) => op.type === "subscription", true: httpSubscriptionLink({ url: ENDPOINT_URL, eventSourceOptions: { withCredentials: true, }, }), false: httpBatchLink({ url: ENDPOINT_URL, maxURLLength: 512, fetch(input, init) { return fetch(input, { credentials: "include", ...init }); }, }), }), }), ],});
export default trpc;