tRPC failed on <no-path>: `headers` was called outside a request scope
I'm using NPM
GET /api/trpc/post.test?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D
6 Replies
I am new to TRPC
Also, this is a T3 app
@gave_one I'm running into the same issue, from the same T3 app. You ever figure it out?
I never figured it out, but I found a different solution also helps me maintain type safety and ease of use
You are calling headers outside of the context of a next request
@Will Lutz I abandoned the T3 stack did stuff manually
I installed the necessary stuff for a next.js app I'm pretty sure you know the stuff with authentication
But the thing I used to replace TRPC is
React server - actions : https://react.dev/reference/rsc/server-actions
React query / TanStack Query v5 : https://tanstack.com/query/latest/docs/framework/react/overview
A good video to explain it : https://www.youtube.com/watch?v=OgVeQVXt7xU&t=314s&pp=ygUVUmVhY3Qgc2VydmVyLCBhY3Rpb25z
Server Actions – React
The library for web and native user interfaces
Overview | TanStack Query React Docs
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze.
Motivation
Josh tried coding
YouTube
Fetching Data Doesn't Get Better Than This
About a month ago I discovered that this data fetching pattern even works, and I'm not going back. This approach is
- type safe
- intuitive
- fast
The only downside I've discovered since is that it doesn't work for webhooks as they NEED to be an API, but other than that, god damn this is great.
-- my links
second channel (in depth videos): ht...
if you do not configure React Query properly you will have headaches