diff --git a/frontend/dist.zip b/frontend/dist.zip deleted file mode 100644 index f241771..0000000 Binary files a/frontend/dist.zip and /dev/null differ diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js index 4f46d01..7a88588 100644 --- a/frontend/src/api/index.js +++ b/frontend/src/api/index.js @@ -41,7 +41,7 @@ const apiService = { // 获取区域列表 getRegions: async () => { try { - const response = await apiClient.get('/api/regions') + const response = await apiClient.get('/regions') return response.data } catch (error) { console.error('获取区域列表失败:', error) @@ -52,7 +52,7 @@ const apiService = { // 获取实例类型列表 getInstanceTypes: async () => { try { - const response = await apiClient.get('/api/instance-types') + const response = await apiClient.get('/instance-types') return response.data } catch (error) { console.error('获取实例类型列表失败:', error) @@ -63,7 +63,7 @@ const apiService = { // 搜索实例 searchInstances: async (params) => { try { - const response = await apiClient.post('/api/search-instances-v2', params) + const response = await apiClient.post('/search-instances-v2', params) return response.data } catch (error) { console.error('搜索实例失败:', error) @@ -74,7 +74,7 @@ const apiService = { // 计算价格 calculatePrice: async (params) => { try { - const response = await apiClient.post('/api/calculate-price', params) + const response = await apiClient.post('/calculate-price', params) return response.data } catch (error) { console.error('计算价格失败:', error) @@ -85,7 +85,7 @@ const apiService = { // 比较价格 comparePrices: async (params) => { try { - const response = await apiClient.post('/api/compare-prices', params) + const response = await apiClient.post('/compare-prices', params) return response.data } catch (error) { console.error('比较价格失败:', error) @@ -96,7 +96,7 @@ const apiService = { // 获取预算估算 getBudgetEstimate: async (params) => { try { - const response = await apiClient.post('/api/budget', params) + const response = await apiClient.post('/budget', params) return response.data } catch (error) { console.error('获取预算估算失败:', error) diff --git a/frontend/src/config.js b/frontend/src/config.js index 4a09bc1..ad4f30a 100644 --- a/frontend/src/config.js +++ b/frontend/src/config.js @@ -1,7 +1,7 @@ // API 配置文件 const config = { - // 后端API基础URL - 从环境变量中读取,如果不存在则使用默认值 - apiBaseUrl: process.env.VUE_APP_API_BASE_URL || 'http://localhost:8000', + // 后端API基础URL 使用相对路径,通过 devServer 代理到后端 + apiBaseUrl: process.env.VUE_APP_API_BASE_URL || '/api', // 其他全局配置 defaultRegion: 'us-east-1', diff --git a/frontend/vue.config.js b/frontend/vue.config.js new file mode 100644 index 0000000..37b9218 --- /dev/null +++ b/frontend/vue.config.js @@ -0,0 +1,16 @@ +module.exports = { + devServer: { + proxy: { + '/api': { + target: 'http://127.0.0.1:8000', + changeOrigin: true, + ws: false, + secure: false, + // 保留 /api 前缀并转发到后端 FastAPI(后端已以 /api 为前缀) + pathRewrite: { '^/api': '/api' }, + }, + }, + }, +} + +