mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-18 06:17:06 +00:00
优化锅巴接口代理
This commit is contained in:
parent
fd735c1daf
commit
22ead6d55e
1 changed files with 16 additions and 6 deletions
|
|
@ -28,16 +28,26 @@ async function Guoba(fastify, options) {
|
||||||
let user = UserInfo(token)
|
let user = UserInfo(token)
|
||||||
if (user && user.autho == 'admin' && body.guobaToken) {
|
if (user && user.autho == 'admin' && body.guobaToken) {
|
||||||
try {
|
try {
|
||||||
let { LoginService } = await import('../../../Guoba-Plugin/server/service/both/LoginService.js')
|
let { getAllWebAddress } = await import('../../../Guoba-Plugin/utils/common.js')
|
||||||
const guobaLoginService = new LoginService()
|
const { custom, local, remote } = await getAllWebAddress()
|
||||||
const { custom, local, remote } = await guobaLoginService.setQuickLogin(user.user)
|
console.log(local[0])
|
||||||
if (local.length > 0) {
|
if (local.length > 0) {
|
||||||
const guobaOptions = {
|
const guobaOptions = {
|
||||||
method: 'GET',
|
method: body.post ? 'POST' : 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Guoba-Access-Token': body.guobaToken
|
'Guoba-Access-Token': body.guobaToken
|
||||||
},
|
}
|
||||||
body: body.data
|
}
|
||||||
|
if (body.data) {
|
||||||
|
if (body.post) {
|
||||||
|
guobaOptions.body = body.data
|
||||||
|
} else {
|
||||||
|
let paramsArray = []
|
||||||
|
Object.keys(body.data).forEach(key => paramsArray.push(key + '=' + body.data[key]))
|
||||||
|
if (paramsArray.length > 0) {
|
||||||
|
body.path += '?' + paramsArray.join('&')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const response = await fetch(`${local[0]}/${body.path}`, guobaOptions)
|
const response = await fetch(`${local[0]}/${body.path}`, guobaOptions)
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue