Next-auth session not being fetched in tRPC context
Next-auth session not being fetched in tRPC context
D
DevR•326d ago
I have got both next-auth and tRPC setup in my next.js app. When I try to fetch the session outside any tRPC route or middleware, It gets resolved properly. I guess Next-auth is working properly the problem is when I try to fetch a session within a tRPC route or middleware. I get null as a result, the user gets
UNAUTHORIZED
response.
Here's my tRPC setup:
src\pages\api\trpc\[trpc].ts
So the problem happens when I am using a protectedProcedure
. I get this error:
publicProcedure
work fine. I am not sure but I think the context is not being initialized properly or something like that. Tried many ways but still unsolved. Your help would mean a lot to me 🙏
My package.json
Note that I am using the Next.js page router not AppPlease help me out and let me know if any other context required 🙏
L
lijuanma1331•324d ago
Hi! Im getting the same error. To reproduce it just clone the websocket/subscriptions, follow the steps and on the first run the error will appear. I think this is the code where it fails
So maybe next-auth related?
My envinfo is
Y
youwontstopme:)•324d ago
Hey, this is how I bypassed this issue, although I still get null tokens/sessions when I am not supposed to, it functions overall:
I also jsut downloaded the websockets-starter example and the only error I got (not using the mocked edition) was:
But the functionality was pretty much working no problem.
L
lijuanma1331•324d ago
This is quite strange🤨
Y
youwontstopme:)•323d ago
very strange indeed... I just don't get it how the websockets-starter is so functional with just the getSession() utility
OS maybe has something to do with this, I am on:
Ubuntu 20.04.6 LTS
D
DevR•317d ago
In my case, outside of tRPC, next-auth is working just fine. Inside trpc, it's not. IDK why.
in tRPC routes, contexts, the session is always null. Because I get this error from Next-auth
Why would next-auth behave like that inside tRPC
4.8KMembers
View on DiscordMore Posts
useMutation not handeling arguments correctly.Hello, I have a mutation setup on the server with the input being an object containing the fields emUpdate Clerk Organization from TRPC Router (T3 Stack)Hello, if anyone got an idea on how to handle this I would highly appreciate it.
I have some organiHow to not send request in specific condition in useQuery()```js
const { data: artists, isLoading } = api.findArtist.useQuery({
name: search,
});
```
TRPCClientError: fetch failedI get the below error when createTRPCProxyClient runs on BE of a Next.JS app hosted on Vercel:
```TinferRouterOutputs not inferringCould anyone point me in the right direction to why my types aren't being inferred here? (Using T3 bModular Router ThoughtsHello, I hope I can convey clearly what I hope to accomplish. To start, I have a monorepo, with a feIssue with trpc fetch when trying to pass Clerk auth to contextI'm currently trying to add Clerk auth to my trpc context, but I just keep getting this error:
`ErrBullMQ + TRPCCurious how to configure BullMQ with TRPC correctly. Currently I have the queue, queueevents, and thTrpc refetches all of the queries when i run a mutationIm running node 16.15.0 with Pnpm
When i run a mutation for some reason all of the queries get refettRPC Client on NodeJS server keeps complaining that no fetcher has been configuredHey, I want to create a tRPC setup where I have one server (works fine) and then a client which is cBest Practice to Fetch a Query OnDemandWhat's the best practice to fetch a query on demand?
I don't have the context for the query's inputOutput Response ShapeI'm wondering, is the output response shape locked in, or can we modify it in any way? For example:
Need help```js
import {initTRPC} from '@trpc/server';
import * as trpcNext from '@trpc/server/adapters/next';useQuery hook modify data on fetch.Hello is it possible to modify the data that is fetched with useQuery hook in tRPC basically im storAccepting a DecoratedProcedure with inputs and outputs that extend some given typesIs there any way to accept a DecoratedProcedure that extends { mutate: Resolver<TProcedure> } where useEffect and useMutation error about conditional rendering of hooksI am using t3 stack with tRPC, and I am trying to mark all emails as seen when the page loads by usiGuide to create an adapterIs there a guide on the docs that explains the basics to create an adapter?Does tRPC websocket client supports wss protocol?After changing the websocket client url from ws to wss, it fails to connect. Tested out the connectiGet the type of context after middlewareHow can I get the type of the context of `adminProcedure` from
`export const adminProcedure = public[How To] Properly use trpc UseQuery based on currently selected itemI have a component with a video element and a flatlist. I want to utilize a trpc query to get the vi