mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 22:52:53 +08:00
fix: remove corsFetch
This commit is contained in:
@@ -14,37 +14,3 @@ export function corsPath(path: string) {
|
||||
|
||||
return `${baseUrl}${path}`;
|
||||
}
|
||||
|
||||
export function corsFetch(
|
||||
url: string,
|
||||
options: RequestInit & {
|
||||
proxyUrl?: string;
|
||||
},
|
||||
) {
|
||||
if (!url.startsWith("http")) {
|
||||
throw Error("[CORS Fetch] url must starts with http/https");
|
||||
}
|
||||
|
||||
let proxyUrl = options.proxyUrl ?? corsPath(ApiPath.Cors);
|
||||
if (!proxyUrl.endsWith("/")) {
|
||||
proxyUrl += "/";
|
||||
}
|
||||
|
||||
url = url.replace("://", "/");
|
||||
|
||||
const corsOptions = {
|
||||
...options,
|
||||
method: "POST",
|
||||
headers: options.method
|
||||
? {
|
||||
...options.headers,
|
||||
method: options.method,
|
||||
}
|
||||
: options.headers,
|
||||
};
|
||||
|
||||
const corsUrl = proxyUrl + url;
|
||||
console.info("[CORS] target = ", corsUrl);
|
||||
|
||||
return fetch(corsUrl, corsOptions);
|
||||
}
|
||||
|
Reference in New Issue
Block a user