Yesterday I had to add some changes to my database table and all the data was lost, which it wasn't a problem because I'm just developing the project. The problem arises after I did that. I started to get this 500 server error in development, Im using supabase as a database and Next js app router latest with prisma, trpc and Next auth with google as a provider.
I'm getting this on the main page Unhandled Runtime Error Error: UNAUTHORIZED
src/trpc/server.ts (61:45) @ from 59 | }) 60 |
.catch((cause: TRPCErrorResponse) => { > 61 | observer.error(TRPCClientError
.from(cause)); | ^ 62 | }); 63 | }), 64 | ],
And I can't access any route. This is the only output I get on the console:
<< query #1 user.getInfo { input: undefined, result:
TRPCClientError: UNAUTHORIZED at TRPCClientError.from
(webpack-internal:///(rsc)/./node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs:44:16)
at eval (webpack-internal:///(rsc)/./src/trpc/server.ts:63:98)
{ meta: undefined, shape: undefined, data: undefined, [cause]: TRPCError: UNAUTHORIZED
at eval (webpack-internal:///(rsc)/./src/server/api/trpc.ts:90:15)
at callRecursive (webpack-internal:///(rsc)/./node_modules/@trpc/server/dist/index.mjs:471:38)
at resolve (webpack-internal:///(rsc)/./node_modules/@trpc/server/dist/index.mjs:501:30)
at callProcedure (webpack-internal:///(rsc)/./node_modules/@trpc/server/dist/config-d5fdbd39.mjs:169:12)
at eval (webpack-internal:///(rsc)/./src/trpc/server.ts:48:91)
{ code: 'UNAUTHORIZED', [cause]: undefined } }, elapsedMs: 182
code in the router server
getInfo: protectedProcedure.query(async ({ ctx }) => {
return ctx.db.user.findUniqueOrThrow({
where: { id: ctx.session.user.id },
});
}),
I've restarted the database and it doesn't work either. Maybe is a problem in the code but I'm guessing it should let me access the home route at least?
The code causing the error was this line
Since I've deleted the database information that line was throwing the error.