Vilian
Vilian
TtRPC
Created by Vilian on 8/24/2023 in #❓-help
nextjs app router `fetchRequestHandler`'s createContext doesn't run.
Hey there, I have the following code:
// /src/app/api/trpc/[trpc]/route.ts
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
import { appRouter } from '~/trpc/root';
import { ENV } from '~/env';
import { createTRPCContext } from '~/trpc/trpc';

const handler = (req: Request) =>
fetchRequestHandler({
req,
router: appRouter,
endpoint: '/api/trpc',
onError: ({ path, error }) => {
if (ENV.NODE_ENV !== 'development') return;
console.error(
`❌ tRPC failed on ${path ?? '<no-path>'}: ${error.message} `
);
},
createContext: createTRPCContext,
});

export { handler as GET, handler as POST };
// /src/app/api/trpc/[trpc]/route.ts
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
import { appRouter } from '~/trpc/root';
import { ENV } from '~/env';
import { createTRPCContext } from '~/trpc/trpc';

const handler = (req: Request) =>
fetchRequestHandler({
req,
router: appRouter,
endpoint: '/api/trpc',
onError: ({ path, error }) => {
if (ENV.NODE_ENV !== 'development') return;
console.error(
`❌ tRPC failed on ${path ?? '<no-path>'}: ${error.message} `
);
},
createContext: createTRPCContext,
});

export { handler as GET, handler as POST };
24 replies
TtRPC
Created by Vilian on 4/1/2023 in #❓-help
context question
Why are the context examples only showing opinionated examples with next/react auth ? Also i find it very confusing that it is not mentioned in the docs what kind of arguments the context function is called with.
51 replies
TtRPC
Created by Vilian on 3/29/2023 in #❓-help
Quickstart not working
2 replies