删除前端构建的dist.zip文件,并更新API配置以使用相对路径,简化API调用。

This commit is contained in:
wangqifan 2025-09-02 14:37:29 +08:00
parent d9c7da8ef9
commit 1192e5c518
4 changed files with 24 additions and 8 deletions

Binary file not shown.

View File

@ -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)

View File

@ -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',

16
frontend/vue.config.js Normal file
View File

@ -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' },
},
},
},
}