import superjson from 'superjson';import { AppRouter } from '../api-types';import { httpBatchLink } from '@trpc/client';import { createTRPCReact } from '@trpc/react-query';export const trpcApi = createTRPCReact<AppRouter>();let token: string = '';export const setToken = (newToken: string) => { console.log('se randeaza asta 3'); token = newToken;};export const trpcApiClientProvider = trpcApi.createClient({ links: [ httpBatchLink({ url: process.env.NEXT_PUBLIC_TRPC_API, fetch(url, options) { return fetch(url, { ...options, credentials: 'include', }); }, headers() { console.log('Headers called 2. Token:', token); return { Authorization: token, }; }, }), ], transformer: superjson,});console.log('se randeaza asta 1');
app.use( cors({ origin: 'http://localhost:3000', credentials: true, }),);