feat: migrate server to 105 and change api base url

feat/unify-api-and-responsive-pages
yannyang 2026-07-05 20:14:38 +08:00
parent b013fff224
commit 6e555cac4e
5 changed files with 16 additions and 15 deletions

View File

@ -36,7 +36,7 @@ npm run build
2、本地执行上传 dist 到服务器): 2、本地执行上传 dist 到服务器):
```bash ```bash
rsync -avz --delete dist/ root@156.230.62.22:/var/www/aura-web/ rsync -avz --delete dist/ root@125.94.46.105:/var/www/aura-web/
``` ```
## Docker ## Docker

View File

@ -1,5 +1,5 @@
import axios from 'axios'; import axios from 'axios';
import { api } from './http'; import { api, API_BASE_URL } from './http';
export interface AuthUser { export interface AuthUser {
id: string; id: string;
@ -12,7 +12,7 @@ export const AuthAPI = {
me: () => api.get<AuthUser>('/auth/me').then((r) => r.data), me: () => api.get<AuthUser>('/auth/me').then((r) => r.data),
verify: async (email: string, password: string) => { verify: async (email: string, password: string) => {
try { try {
const res = await axios.post('https://api.hoyidata.com/aura/v1/urser', { email, password }, { timeout: 3000 }); const res = await axios.post(`${API_BASE_URL}/urser`, { email, password }, { timeout: 3000 });
return res.data; return res.data;
} catch (e) { } catch (e) {
console.warn('Backend /urser not available, fallback to mock true', e); console.warn('Backend /urser not available, fallback to mock true', e);

View File

@ -1,6 +1,6 @@
import axios from 'axios'; import axios from 'axios';
export const API_BASE_URL = 'https://api.hoyidata.com/aura/v1'; export const API_BASE_URL = 'https://tianchaoai.cc/aura/v1';
const APP_BASE = (import.meta.env.BASE_URL || '/').replace(/\/$/, ''); const APP_BASE = (import.meta.env.BASE_URL || '/').replace(/\/$/, '');
export const withAppBase = (path: string) => `${APP_BASE}${path.startsWith('/') ? path : `/${path}`}`; export const withAppBase = (path: string) => `${APP_BASE}${path.startsWith('/') ? path : `/${path}`}`;
export const withApiBase = (path: string) => `${API_BASE_URL}${path.startsWith('/') ? path : `/${path}`}`; export const withApiBase = (path: string) => `${API_BASE_URL}${path.startsWith('/') ? path : `/${path}`}`;

View File

@ -1,4 +1,5 @@
import type { ChatMessage } from './chat'; import type { ChatMessage } from './chat';
import { API_BASE_URL } from './http';
export interface StreamEvents { export interface StreamEvents {
onMeta?: (data: any) => void; onMeta?: (data: any) => void;
@ -30,7 +31,7 @@ export async function streamChat(
modelId?: string, modelId?: string,
imageUrls?: string[] imageUrls?: string[]
) { ) {
const resp = await fetch(`https://api.hoyidata.com/aura/v1/rooms/${roomId}/messages/stream`, { const resp = await fetch(`${API_BASE_URL}/rooms/${roomId}/messages/stream`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'text/event-stream' }, headers: { 'Content-Type': 'application/json', Accept: 'text/event-stream' },
body: JSON.stringify({ body: JSON.stringify({
@ -54,7 +55,7 @@ export async function regenerateMessage(
overrides?: ModelOverrides, overrides?: ModelOverrides,
attachmentsText?: string attachmentsText?: string
) { ) {
const resp = await fetch(`https://api.hoyidata.com/aura/v1/chat/${agentId}/messages/${messageId}/regenerate`, { const resp = await fetch(`${API_BASE_URL}/chat/${agentId}/messages/${messageId}/regenerate`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'text/event-stream' }, headers: { 'Content-Type': 'application/json', Accept: 'text/event-stream' },
body: JSON.stringify({ overrides, attachmentsText }), body: JSON.stringify({ overrides, attachmentsText }),

View File

@ -1,15 +1,15 @@
import { defineConfig, loadEnv } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
// 默认走 Go 后端 :4001要回退 Node 后端就 set VITE_API_TARGET=http://localhost:4000 // 默认走 Go 后端 :4001要回退 Node 后端就 set VITE_API_TARGET=http://localhost:4000
export default defineConfig(({ command, mode }) => { export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), ''); const env = loadEnv(mode, process.cwd(), '');
const target = env.VITE_API_TARGET || 'https://api.hoyidata.com'; const target = env.VITE_API_TARGET || 'https://tianchaoai.cc';
return { return {
// 本地开发走根路径,生产构建部署到 /aura 子路径 // 本地开发走根路径,生产构建部署到 /aura 子路径
base: command === 'serve' ? '/' : '/aura/', base: command === 'serve' ? '/' : '/aura/',
plugins: [react()], plugins: [react()],
server: { server: {
port: 3001, port: 3001,
proxy: { proxy: {