mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 18:57:07 +08:00
fix: remove corsFetch
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { STORAGE_KEY } from "@/app/constant";
|
||||
import { SyncStore } from "@/app/store/sync";
|
||||
import { corsFetch } from "../cors";
|
||||
import { chunks } from "../format";
|
||||
|
||||
export type UpstashConfig = SyncStore["upstash"];
|
||||
@@ -18,10 +17,9 @@ export function createUpstashClient(store: SyncStore) {
|
||||
return {
|
||||
async check() {
|
||||
try {
|
||||
const res = await corsFetch(this.path(`get/${storeKey}`), {
|
||||
const res = await fetch(this.path(`get/${storeKey}`, proxyUrl), {
|
||||
method: "GET",
|
||||
headers: this.headers(),
|
||||
proxyUrl,
|
||||
});
|
||||
console.log("[Upstash] check", res.status, res.statusText);
|
||||
return [200].includes(res.status);
|
||||
@@ -32,10 +30,9 @@ export function createUpstashClient(store: SyncStore) {
|
||||
},
|
||||
|
||||
async redisGet(key: string) {
|
||||
const res = await corsFetch(this.path(`get/${key}`), {
|
||||
const res = await fetch(this.path(`get/${key}`, proxyUrl), {
|
||||
method: "GET",
|
||||
headers: this.headers(),
|
||||
proxyUrl,
|
||||
});
|
||||
|
||||
console.log("[Upstash] get key = ", key, res.status, res.statusText);
|
||||
@@ -45,11 +42,10 @@ export function createUpstashClient(store: SyncStore) {
|
||||
},
|
||||
|
||||
async redisSet(key: string, value: string) {
|
||||
const res = await corsFetch(this.path(`set/${key}`), {
|
||||
const res = await fetch(this.path(`set/${key}`, proxyUrl), {
|
||||
method: "POST",
|
||||
headers: this.headers(),
|
||||
body: value,
|
||||
proxyUrl,
|
||||
});
|
||||
|
||||
console.log("[Upstash] set key = ", key, res.status, res.statusText);
|
||||
@@ -84,7 +80,7 @@ export function createUpstashClient(store: SyncStore) {
|
||||
Authorization: `Bearer ${config.apiKey}`,
|
||||
};
|
||||
},
|
||||
path(path: string) {
|
||||
path(path: string, proxyUrl: string = "") {
|
||||
// let url = config.endpoint;
|
||||
|
||||
if (!path.endsWith("/")) {
|
||||
@@ -94,7 +90,11 @@ export function createUpstashClient(store: SyncStore) {
|
||||
path = path.slice(1);
|
||||
}
|
||||
|
||||
let url = new URL("/api/upstash/" + path);
|
||||
if (proxyUrl.length > 0 && !proxyUrl.endsWith("/")) {
|
||||
proxyUrl += "/";
|
||||
}
|
||||
|
||||
let url = new URL(proxyUrl + "/api/upstash/" + path);
|
||||
|
||||
// add query params
|
||||
url.searchParams.append("endpoint", config.endpoint);
|
||||
|
Reference in New Issue
Block a user