lambo1994
lambo199412mo ago

route needs jwt but it doesn't

hi i do have a public route but when i i call it on the front end it requires a jwt token SERVER import { publicProcedure, router } from '../../routes/trpc-init-route'; import { createUserSchema } from './users.schema'; import { createUserHandler, getUserHandler } from './users.controller'; export const usersRouter = router({ helloUser: publicProcedure.query(() => { return { data: 'hello world!!!' } }), createUser: publicProcedure .input(createUserSchema) .mutation(({ input }) => createUserHandler({ input })), getUser: publicProcedure .input(createUserSchema) .mutation(({ input }) => getUserHandler({ input })), }); export type UsersRouter = typeof usersRouter; CLIENT export const setToken = (newToken: string) => { token = newToken; }; export const trpc = createTRPCReact<AppRouter>(); export const queryClient = new QueryClient(); export const trpcClient = trpc.createClient({ links: [ httpBatchLink({ url: 'http://localhost:4040/trpc', async headers() { return { authorization: token } } }), ] })
1 Reply
Dani;
Dani;12mo ago
Maybe you have some auth-checks in a middleware or in the function which creates the tRPC context?