TRPC Internal Server Error

I keep getting this error, everything was working until I edited trpc.ts to make a private procedure. import { type CreateNextContextOptions } from "@trpc/server/adapters/next"; import { prisma } from "~/server/db"; export const createTRPCContext = (opts: CreateNextContextOptions) => { const { req } = opts; const sesh = getAuth(req); const userId = sesh.userId; return { prisma, userId, }; }; import { initTRPC, TRPCError } from "@trpc/server"; import superjson from "superjson"; import { ZodError } from "zod"; import { getAuth } from "@clerk/nextjs/server"; const t = initTRPC.context<typeof createTRPCContext>().create({ transformer: superjson, errorFormatter({ shape, error }) { return { ...shape, data: { ...shape.data, zodError: error.cause instanceof ZodError ? error.cause.flatten() : null, }, }; }, }); export const createTRPCRouter = t.router; export const publicProcedure = t.procedure; const enforceUserIsAuthed = t.middleware(async ({ ctx, next }) => { if (!ctx.userId) { throw new TRPCError({ code: "UNAUTHORIZED", }); } return next({ ctx: { userId: ctx.userId, }, }); }); export const privateProcedure = t.procedure.use(enforceUserIsAuthed);
4 Replies
cajayethecreator
cajayethecreatorOP2y ago
the error
cajayethecreator
cajayethecreatorOP2y ago
I did use withClerkMiddleware in my next.js middleware file
isaac_way
isaac_way2y ago
Did you make sure your middleware matcher is configured correctly
cajayethecreator
cajayethecreatorOP2y ago
blessjmg middlware.ts was not in the src folder thank you
Want results from more Discord servers?
Add your server