refactor(部署): 重构部署架构,使用本地代理服务器替代环境变量配置
- 删除 Dockerfile.dev 和 entrypoint.sh,简化开发环境配置 - 修改 Dockerfile 使用 node 基础镜像并添加代理服务器 - 新增 proxy-server.js 处理 API 请求代理 - 更新 nginx 配置指向本地代理服务 - 修改前端请求添加自定义 base URL 头支持
This commit is contained in:
@@ -761,12 +761,18 @@ export function useThinkFlow({ t, locale }: { t: Translate; locale: Ref<string>
|
||||
const finalApiKey = apiConfig.mode === 'default' ? useConfig.apiKey || API_KEY : useConfig.apiKey
|
||||
|
||||
try {
|
||||
const headers: any = {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
}
|
||||
|
||||
if (apiConfig.mode !== 'default' && useConfig.baseUrl) {
|
||||
headers['X-Custom-Base-Url'] = useConfig.baseUrl
|
||||
}
|
||||
|
||||
const response = await fetch(useConfig.baseUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
},
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
model: useConfig.model,
|
||||
messages: [
|
||||
@@ -813,12 +819,19 @@ export function useThinkFlow({ t, locale }: { t: Translate; locale: Ref<string>
|
||||
const detail = node.data.description || ''
|
||||
const path = findPathToNode(nodeId)
|
||||
const context = path.length > 5 ? `... -> ${path.slice(-4).join(' -> ')}` : path.join(' -> ')
|
||||
|
||||
const headers: any = {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
}
|
||||
|
||||
if (apiConfig.mode !== 'default' && useConfig.baseUrl) {
|
||||
headers['X-Custom-Base-Url'] = useConfig.baseUrl
|
||||
}
|
||||
|
||||
const response = await fetch(useConfig.baseUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
},
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
model: useConfig.model,
|
||||
prompt: t('prompts.image', { topic, detail, context })
|
||||
@@ -869,12 +882,18 @@ export function useThinkFlow({ t, locale }: { t: Translate; locale: Ref<string>
|
||||
const path = findPathToNode(nodeId)
|
||||
const context = path.join(' -> ')
|
||||
|
||||
const headers: any = {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
}
|
||||
|
||||
if (apiConfig.mode !== 'default' && useConfig.baseUrl) {
|
||||
headers['X-Custom-Base-Url'] = useConfig.baseUrl
|
||||
}
|
||||
|
||||
const response = await fetch(useConfig.baseUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
},
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
model: useConfig.model,
|
||||
messages: [{ role: 'user', content: t('prompts.deepDivePrompt', { rootTopic, context, topic, detail }) }]
|
||||
@@ -1031,12 +1050,18 @@ export function useThinkFlow({ t, locale }: { t: Translate; locale: Ref<string>
|
||||
const finalApiKey = apiConfig.mode === 'default' ? useConfig.apiKey || API_KEY : useConfig.apiKey
|
||||
|
||||
try {
|
||||
const headers: any = {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
}
|
||||
|
||||
if (apiConfig.mode !== 'default' && useConfig.baseUrl) {
|
||||
headers['X-Custom-Base-Url'] = useConfig.baseUrl
|
||||
}
|
||||
|
||||
const response = await fetch(useConfig.baseUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${finalApiKey}`
|
||||
},
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
model: useConfig.model,
|
||||
messages: [
|
||||
|
||||
Reference in New Issue
Block a user