refactor(env): 修改 API基础路径并调整请求配置- 在 request.js 中将 baseURL 添加 /api 路径

- 移除 .env 文件中的末尾斜杠
- 注释掉不必要的请求头处理代码
-优化响应拦截器中的状态码判断逻辑
This commit is contained in:
陈昱达
2025-03-13 19:56:50 +08:00
parent ef59888490
commit 23b3566084
3 changed files with 11 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
# .env.development
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com/
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com
VITE_APP_ENV=development
VITE_APP_CURRENTMODE=dev
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc

View File

@@ -1,5 +1,5 @@
# .env.development
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com/
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com
VITE_APP_ENV=uat
VITE_APP_CURRENTMODE=uat
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc

View File

@@ -13,7 +13,7 @@ const baseURL = config.default.proxyUrl;
// create an axios instance
const service = axios.create({
// url = base url + request url
baseURL: `${baseURL}`,
baseURL: `${baseURL}/api`,
// withCredentials: true, // send cookies when cross-domain requests
// request timeout
timeout: 30000
@@ -26,10 +26,10 @@ service.interceptors.request.use(
config.headers.Accept = 'application/json';
}
config.headers.Authorization = `${localStorage.getItem('plantToken')}`;
if (!config.headers.remoteIp) {
config.baseURL += '/api';
}
delete config.headers.host;
// if (!config.headers.remoteIp) {
// config.baseURL += '/api';
// }
// delete config.headers.host;
config.headers.remoteIp = localStorage.getItem('plantIp') || '127.0.0.1';
// if (store.state.common.token) {
// config.headers['Login-Type'] = 'pc';
@@ -44,10 +44,10 @@ service.interceptors.request.use(
service.interceptors.response.use(
(response) => {
if (
response.status === 200
|| response.status === 201
|| response.status === 202
|| response.status === 204
response.status === 200 ||
response.status === 201 ||
response.status === 202 ||
response.status === 204
) {
if (response.config.method === 'put') {
// message.success('保存中...');