Fossil
TTCTheo's Typesafe Cult
•Created by Kenzo on 7/8/2024 in #questions
Caching does not work with trpc in Next, what would you do?
I feel like a tremendous pleb.
The regular approach of adding headers to
next.config.js
adds the correct Cache-Control headers to the response, and the server respects them.
cc @Kenzo
26 replies
TTCTheo's Typesafe Cult
•Created by Lukem121 on 9/11/2023 in #questions
Error: Invariant: headers() expects to have requestAsyncStorage, none available.
For me this happened when calling
headers()
as part of the context for createServerSideHelpers
.
It is actually covered here: "That also means that you don't have the request and response at hand like you usually do. Make sure you're instantiating the server-side helpers with a context without req & res" https://trpc.io/docs/client/nextjs/server-side-helpers#1-internal-router5 replies
TTCTheo's Typesafe Cult
•Created by v-for-v on 4/21/2024 in #questions
Bug!? Server side calls are not being cached
Apologies 'Greater' is misleading here. Let me rephrase:
Your TRPC endpoints can still be queried directly, and will have the previous issue of being uncached.
Thus - your TRPC endpoints themselves are a DDoS vector (regardless of how you're querying them in your app)
54 replies
TTCTheo's Typesafe Cult
•Created by v-for-v on 4/21/2024 in #questions
Bug!? Server side calls are not being cached
Yea the endpoints would still be exposed and uncached in prod though - so greater potential for a DDoS?
54 replies
TTCTheo's Typesafe Cult
•Created by v-for-v on 4/21/2024 in #questions
Bug!? Server side calls are not being cached
Yea the existing trpc docs refer to a cacheing method (setting cache-control headers) which are ignored with the app router.
I've found no way to control the tRPC cache with the app router
54 replies
TTCTheo's Typesafe Cult
•Created by Bartholomeas on 4/6/2024 in #questions
Refetching/revalidating server query with TRPC
Yea shades of the same issue - I have found no documentation online for how to handle trpc endpoint cacheing/revalidation with Next Ap Router https://discord.com/channels/966627436387266600/1212328159991570452/1212328159991570452 & https://discord.com/channels/966627436387266600/1228337408563740803
12 replies
How to cache trpc server request next.js app router
Currently documented tRPC cacheing methods (https://trpc.io/docs/server/caching) won't work as they rely on setting headers which NextJs now overrides (https://nextjs.org/docs/app/api-reference/next-config-js/headers#cache-control)
24 replies
TTCTheo's Typesafe Cult
•Created by Gnark | David on 2/28/2024 in #questions
Cache with TRPC app router
Currently documented tRPC cacheing methods (https://trpc.io/docs/server/caching) won't work as they rely on setting headers which NextJs now overrides (https://nextjs.org/docs/app/api-reference/next-config-js/headers#cache-control)
6 replies
TTCTheo's Typesafe Cult
•Created by Gnark | David on 2/28/2024 in #questions
Cache with TRPC app router
Bump. Cannot find a way to have caching respected for trpc endpoints.
[email protected]
I'm able to set cache-control
headers in the createCallerFactory
context, or fetchRequestHandler
's responseContext
but it doesnt seem to have an impact6 replies