update
This commit is contained in:
parent
896123b3a2
commit
6c1864b51f
@ -1,22 +1,9 @@
|
||||
import axios from 'axios'
|
||||
|
||||
// 根据环境变量确定基础URL
|
||||
const getBaseURL = () => {
|
||||
// 从环境变量 APP_ENV 获取当前的环境
|
||||
const appEnv = process.env.APP_ENV || 'local'
|
||||
switch (appEnv) {
|
||||
case 'dev':
|
||||
return 'https://api-dev.beefast.co'
|
||||
case 'prd':
|
||||
return 'https://api.beefast.co'
|
||||
default:
|
||||
return 'http://localhost:8000'
|
||||
}
|
||||
}
|
||||
import config from './config'
|
||||
|
||||
// 创建 axios 实例
|
||||
const apiClient = axios.create({
|
||||
baseURL: getBaseURL(),
|
||||
baseURL: config.API_URL,
|
||||
timeout: 10000, // 请求超时时间
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
13
src/services/config.js
Normal file
13
src/services/config.js
Normal file
@ -0,0 +1,13 @@
|
||||
const env = {
|
||||
development: {
|
||||
API_URL: 'http://localhost:8000'
|
||||
},
|
||||
testing: {
|
||||
API_URL: process.env.VUE_APP_API_URL || 'https://api-dev.beefast.co'
|
||||
},
|
||||
production: {
|
||||
API_URL: process.env.VUE_APP_API_URL || 'https://api.beefast.co'
|
||||
}
|
||||
}
|
||||
|
||||
export default env[process.env.NODE_ENV || 'development']
|
||||
Loading…
Reference in New Issue
Block a user