I'm having a problem using passport.js to authenticate jwt with tRPC middleware. I tried calling thre next() function in the callback of passport.authenticate function but it doesn't seem to be working and results in the error,
{"message": "No result from middlewares - did you forget to 'return next()'?", "code": -32603}
below is my code,
const t = initTRPC.create();
const jwtMiddleware = t.middleware(async ({ ctx, next }) =>
passport.authenticate('jwt', { session: false }, async (err) => {
if (err) throw new TRPCError({ code: 'UNAUTHORIZED' });
// Calling next() here doesn't seem to be working
return next();
})(ctx.req, ctx.res, next),
);
const authedProcedure = t.procedure.use(jwtMiddleware);
thanks for the help in advanced!