wangjuncheng
8 天以前 f60f7c614e60221ed7c0ddb93c52608e86f4b57e
src/api/requestTR.js
@@ -1,25 +1,13 @@
import axios from "axios";
// 判断当前是否是开发环境
let API_URL;
if (process.env.NODE_ENV === 'development') {
  // 开发环境使用 '/api'
  API_URL = '/api';
} else {
  // 生产环境使用实际的配置地址
  API_URL = `${BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL}/api`;
}
// 创建 Axios 实例
const instance = axios.create({
  baseURL: API_URL,
  // timeout: 1000 * 60, // 请求超时时间(单位:毫秒)
  baseURL: "/api", // 使用你配置的 /auth 代理
  timeout: 1000 * 60, // 请求超时时间(单位:毫秒)
  headers: {
    "Content-Type": "application/x-www-form-urlencoded", // 默认请求头
    "Content-Type": "application/x-www-form-urlencoded", // 默认请求头application/json
  },
});
// 请求拦截器
// instance.interceptors.request.use(
//   (config) => {