diff --git a/app/api/common.ts b/app/api/common.ts index 2f7d4c3d3..d25cc1cd9 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -8,8 +8,6 @@ const BASE_URL = process.env.BASE_URL ?? OPENAI_URL; export async function requestOpenai(req: NextRequest) { const apiKey = req.headers.get("token"); const openaiPath = req.headers.get("path"); - const fetchCache = - req.headers.get("fetch-cache") == "enable" ? "default" : "no-store"; let baseUrl = BASE_URL; @@ -25,7 +23,7 @@ export async function requestOpenai(req: NextRequest) { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, - cache: fetchCache, + cache: "no-store", method: req.method, body: req.body, }); diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 9f62d5017..3bde0089a 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -207,7 +207,7 @@ export function Settings(props: { closeSettings: () => void }) { const [loadingUsage, setLoadingUsage] = useState(false); function checkUsage(force: boolean = false) { setLoadingUsage(true); - updateStore.updateUsage(true).finally(() => { + updateStore.updateUsage(force).finally(() => { setLoadingUsage(false); }); } diff --git a/app/requests.ts b/app/requests.ts index e1bf33b58..59f8dd3c1 100644 --- a/app/requests.ts +++ b/app/requests.ts @@ -49,17 +49,15 @@ function getHeaders() { } export function requestOpenaiClient(path: string) { - return (body: any, method: string = "POST", fetchCache: boolean = true) => + return (body: any, method: string = "POST") => fetch("/api/openai?_vercel_no_cache=1", { method, headers: { "Content-Type": "application/json", path, ...getHeaders(), - "fetch-cache": fetchCache ? "enable" : "disable", }, body: body && JSON.stringify(body), - cache: fetchCache ? "default" : "no-store", //https://beta.nextjs.org/docs/data-fetching/fetching#dynamic-data-fetching }); } @@ -92,12 +90,8 @@ export async function requestUsage() { const [used, subs] = await Promise.all([ requestOpenaiClient( `dashboard/billing/usage?start_date=${startDate}&end_date=${endDate}`, - )(null, "GET", useFetchCache), - requestOpenaiClient("dashboard/billing/subscription")( - null, - "GET", - useFetchCache, - ), + )(null, "GET"), + requestOpenaiClient("dashboard/billing/subscription")(null, "GET"), ]); const response = (await used.json()) as {