santosa
santosa
CDCloudflare Developers
Created by santosa on 12/15/2023 in #workers-help
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?
import { createClient } from "@libsql/client/web";

const customFetch = (
input: RequestInfo | URL,
init?: RequestInit | undefined
) => {
return fetch(input, {
cf: {},
});
};
export const getClientLibsql = () => {
return createClient({
url: process.env.LIBSQL_URL || "",
authToken: process.env.LIBSQL_TOKEN,
fetch: customFetch,
});
};
import { createClient } from "@libsql/client/web";

const customFetch = (
input: RequestInfo | URL,
init?: RequestInit | undefined
) => {
return fetch(input, {
cf: {},
});
};
export const getClientLibsql = () => {
return createClient({
url: process.env.LIBSQL_URL || "",
authToken: process.env.LIBSQL_TOKEN,
fetch: customFetch,
});
};
7 replies