fetchRequestHandler({
endpoint: '/api/trpc',
req,
router: appRouter,
createContext: () => ({}),
onError: async ({ error, req, input }) => {
console.log('TRPC route error', error);
let body = null;
try {
if (req.method === 'POST') {
const isJsonContentType =
!!req.headers.get('Content-Type')?.includes('application/json') ??
false;
body = isJsonContentType ? await req.json() : await req.text();
}
} catch () {
// here it would throw that the body is unusable
}
console.log(
req.method,
req.headers.get('Content-Type'),
{ body, input },
// here: both, body and input are empty
);
// ...
}
}
fetchRequestHandler({
endpoint: '/api/trpc',
req,
router: appRouter,
createContext: () => ({}),
onError: async ({ error, req, input }) => {
console.log('TRPC route error', error);
let body = null;
try {
if (req.method === 'POST') {
const isJsonContentType =
!!req.headers.get('Content-Type')?.includes('application/json') ??
false;
body = isJsonContentType ? await req.json() : await req.text();
}
} catch () {
// here it would throw that the body is unusable
}
console.log(
req.method,
req.headers.get('Content-Type'),
{ body, input },
// here: both, body and input are empty
);
// ...
}
}