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.
on trpc I am using the unstable_httpBatchStreamLink
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}`);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;
},
}),
],
}),
);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;
},
}),
],
}),
);