[feat] added tokens for reverse proxy
This commit is contained in:
@@ -201,7 +201,8 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
headers: {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(headers)),
|
||||
"risu-url": encodeURIComponent(replacerURL),
|
||||
"Content-Type": "application/json"
|
||||
"Content-Type": "application/json",
|
||||
"x-risu-tk": "use"
|
||||
},
|
||||
method: "POST",
|
||||
signal: abortSignal
|
||||
@@ -268,7 +269,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
const res = await globalFetch(replacerURL, {
|
||||
body: body,
|
||||
headers: headers,
|
||||
abortSignal
|
||||
abortSignal,
|
||||
})
|
||||
|
||||
const dat = res.data as any
|
||||
|
||||
@@ -437,10 +437,18 @@ export async function loadData() {
|
||||
|
||||
const knownHostes = ["localhost","127.0.0.1"]
|
||||
|
||||
export async function globalFetch(url:string, arg:{plainFetchForce?:boolean,body?:any,headers?:{[key:string]:string}, rawResponse?:boolean, method?:"POST"|"GET", abortSignal?:AbortSignal} = {}): Promise<{
|
||||
export async function globalFetch(url:string, arg:{
|
||||
plainFetchForce?:boolean,
|
||||
body?:any,
|
||||
headers?:{[key:string]:string},
|
||||
rawResponse?:boolean,
|
||||
method?:"POST"|"GET",
|
||||
abortSignal?:AbortSignal,
|
||||
useRisuToken?:boolean
|
||||
} = {}): Promise<{
|
||||
ok: boolean;
|
||||
data: any;
|
||||
headers:{[key:string]:string}
|
||||
headers:{[key:string]:string},
|
||||
}> {
|
||||
try {
|
||||
const db = get(DataBase)
|
||||
@@ -625,13 +633,18 @@ export async function globalFetch(url:string, arg:{plainFetchForce?:boolean,body
|
||||
if(arg.rawResponse){
|
||||
const furl = ((!isTauri) && (!isNodeServer)) ? `${hubURL}/proxy2` : `/proxy2`
|
||||
|
||||
let headers = {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||
"risu-url": encodeURIComponent(url),
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
if(arg.useRisuToken){
|
||||
headers["x-risu-tk"] = "use"
|
||||
}
|
||||
|
||||
const da = await fetch(furl, {
|
||||
body: body,
|
||||
headers: {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||
"risu-url": encodeURIComponent(url),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
headers: headers,
|
||||
method: method,
|
||||
signal: arg.abortSignal
|
||||
})
|
||||
@@ -646,13 +659,17 @@ export async function globalFetch(url:string, arg:{plainFetchForce?:boolean,body
|
||||
else{
|
||||
const furl = ((!isTauri) && (!isNodeServer)) ? `${hubURL}/proxy2` : `/proxy2`
|
||||
|
||||
let headers = {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||
"risu-url": encodeURIComponent(url),
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
if(arg.useRisuToken){
|
||||
headers["x-risu-tk"] = "use"
|
||||
}
|
||||
const da = await fetch(furl, {
|
||||
body: body,
|
||||
headers: {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||
"risu-url": encodeURIComponent(url),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
headers: headers,
|
||||
method: method
|
||||
})
|
||||
const daText = await da.text()
|
||||
|
||||
Reference in New Issue
Block a user