cf options in fetch with typecript
Im fetching from turso in my Next.js app some data.
I need it to not be cached and I read that I could change those options with cf as described here https://developers.cloudflare.com/workers/examples/cache-using-fetch/
I have a custom fetch that I use for my libsql client
But it cries and says that cf cant be used, is there any workaround for this?
4 Replies
I don't believe the cf property would do anything on the fetch anyway because of how Next.js patches the fetch function. Anything caching with fetch should be handled through the Next.js fetch cache stuff - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#opting-out-of-data-caching
Data Fetching: Fetching, Caching, and Revalidating | Next.js
Learn how to fetch, cache, and revalidate data in your Next.js application.
You were correct sir, this did the trick
Then now I'm kinda confused, there is no cache from cloudflare at all if I don't set anything in the cf vars? if I ever need them, the typescript stuff would persist?
In Next.js apps, you use
next.revalidate
and cache
, and the fetch cache is then handled internally in the adaptor, due to how next.js' data fetching worksAhhhh, I think I got it, thank you