更新 CNB 配置获取逻辑,修复未授权问题,添加测试文件
This commit is contained in:
@@ -4,7 +4,9 @@ import { useKey } from '@kevisual/context';
|
||||
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
||||
export const getConfig = async (opts: { token?: string }) => {
|
||||
const kevisualEnv = useKey('KEVISUAL_ENV')
|
||||
const baseUrl = kevisualEnv === 'production' ? 'https://kevisual.cn/api/router' : 'https://kevisual.xiongxiao.me/api/router';
|
||||
const isCNB = useKey('CNB');
|
||||
let isProduction = kevisualEnv !== 'development' || (isCNB && !kevisualEnv);
|
||||
const baseUrl = isProduction ? 'https://kevisual.cn/api/router' : 'https://kevisual.xiongxiao.me/api/router';
|
||||
const res = await fetch(baseUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
@@ -70,6 +72,8 @@ export class CNBManager {
|
||||
if (token) {
|
||||
return this.addCNB({ username, token, cookie })
|
||||
}
|
||||
} else {
|
||||
console.error('获取 CNB 配置失败', username, res)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user