mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-27 02:59:22 +08:00
fix: Add cache fix for request Usage
Added cache: 'no-store' parameter to fetch to avoid caching issue in non-Vercel deployment environment(ref: https://beta.nextjs.org/docs/data-fetching/fetching#dynamic-data-fetching)
This commit is contained in:
@@ -8,6 +8,8 @@ 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;
|
||||
|
||||
@@ -23,6 +25,7 @@ export async function requestOpenai(req: NextRequest) {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
},
|
||||
cache: fetchCache,
|
||||
method: req.method,
|
||||
body: req.body,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user