azteca69A
tRPC14mo ago
1 reply
azteca69

Skew protection Vercel TRPC

Was wondering if I can enable vercel skew protection for trpc.

According to docs, adding the dpl query should enable it.

const query =
  process.env.VERCEL_SKEW_PROTECTION_ENABLED === '1'
    ? `?dpl=${process.env.VERCEL_DEPLOYMENT_ID}`
    : '';
 
const res = await fetch(`/get${query}`);


on trpc I am using the unstable_httpBatchStreamLink

const [trpcClient] = useState(() =>
    api.createClient({
      links: [
        loggerLink({
          enabled: (op) =>
            env.NODE_ENV === 'development' ||
            (op.direction === 'down' && op.result instanceof Error),
        }),
        unstable_httpBatchStreamLink({
          transformer: SuperJSON,
          url: `${getBaseUrl()}/new-api/trpc`,
          headers() {
            const headers = new Headers();
            headers.set('x-trpc-source', 'nextjs-react');
            return headers;
          },
        }),
      ],
    }),
  );
Was this page helpful?