fix(config): 更新AI API配置以支持生产环境HTTPS访问
- 将生产环境AI API URL从 http://127.0.0.1:11434/api/v1 修改为 https://ai-api.websoft.top/api/v1 - 在ai组件中移除硬编码的本地地址,统一使用HTTPS反向代理URL - 添加重要注释说明浏览器生产环境中不应使用127.0.0.1地址 - 更新示例环境变量配置,将VITE_AI_API_URL和VITE_OLLAMA_API_URL设置为同源反向代理路径 - 解决浏览器混合内容安全策略导致的API调用失败问题
This commit is contained in:
@@ -20,7 +20,7 @@ export const FILE_SERVER =
|
||||
export const AI_API_URL =
|
||||
import.meta.env.VITE_AI_API_URL ||
|
||||
// Prefer same-origin reverse proxy during local development to avoid CORS.
|
||||
(import.meta.env.DEV ? '/ai-proxy' : 'http://127.0.0.1:11434/api/v1');
|
||||
(import.meta.env.DEV ? '/ai-proxy' : 'https://ai-api.websoft.top/api/v1');
|
||||
|
||||
// Ollama native API endpoint (usually http://host:11434).
|
||||
// Note: browsers cannot call http from an https site (mixed-content); prefer same-origin proxy.
|
||||
|
||||
@@ -12,9 +12,12 @@
|
||||
|
||||
// Hardcode endpoint to avoid going through mp.websoft.top `/proxy`.
|
||||
// The API methods append `/api/*` paths.
|
||||
const BASE_URL = import.meta.env.PROD
|
||||
? 'http://127.0.0.1:11434'
|
||||
: 'https://ai-api.websoft.top';
|
||||
//
|
||||
// IMPORTANT: do not use `127.0.0.1` in browser production builds:
|
||||
// it points to the visitor's machine, not your server.
|
||||
// If you want to use server-local Ollama (`127.0.0.1:11434`), put it behind an HTTPS reverse proxy
|
||||
// (e.g. `https://ai-api.websoft.top` or same-origin `/proxy`).
|
||||
const BASE_URL = 'https://ai-api.websoft.top';
|
||||
|
||||
const modelLoading = ref(false);
|
||||
const models = ref<Array<{ id: string; name?: string }>>([]);
|
||||
|
||||
Reference in New Issue
Block a user