The NextJS app compiled as production works on my local but on Vercel I’m facing the authentication issue in trcp.
The trpc endpoints are defined with:
export const protectedProcedure = procedure.use(async (opts) => {
const { req } = opts.ctx;
const nreq = req!;
const jwt = await handler(nreq);
if (!jwt || !jwt.id) {
console.log("jwt>>>>>>>>", jwt);
throw new Error("User not authenticated B");
}
// Extend the context to include `userId`
return opts.next({
ctx: {
...opts.ctx,
userId: jwt.id,
} as Context,
});
});
On Vercel the trpc throw: throw new Error(“User not authenticated B”);
I’ve checked the environment varaibles and they all all in order. I can even authenticate in my app on Vercel and see my loggedin profile on the main page (which is not using the trcp) but as soon as I navigate to the page which uses trcp I’m experiencing the issue.