diff --git a/.env.development b/.env.development index 5e73aa7..0252384 100644 --- a/.env.development +++ b/.env.development @@ -5,10 +5,10 @@ VITE_ENV = 'development' VITE_HOST = 'https://test.gitcode.net' # 接口地址 -VITE_API_HOST = '/official' +VITE_API_HOST = '/gateway/official' # devPress接口地址 -VITE_DEV_API_HOST = '/official' +VITE_DEV_API_HOST = '/gateway/official' # devPress地址 VITE_DEV_HOST = 'https://test.gitcode.net' diff --git a/src/utils/request.ts b/src/utils/request.ts index dff8a73..c5ad813 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -7,6 +7,7 @@ import { useGlobalInfoStore } from '@/stores/Global'; import { cutParamsInUrl, getSignUtmSource } from './index'; import { Message } from 'vue-devui/message'; import degradeInterceptor from './degradeInterceptor'; +import { useAccountStore } from '@/stores/user'; const handleError = dealWarning(); @@ -67,9 +68,14 @@ const refreshToken = async () => axios.request({ }); const proxyService = (params: any, customConfigs?: CustomConfigs) => { + const account = useAccountStore(); const service = axios.create({ baseURL: params.apiType === 'devApi' ? baseDevURL : baseURL, timeout: 15000, + headers: { + 'DP_TOKEN': account.accountInfo.access_token, + 'DP_REFRESH_TOKEN': account.accountInfo.refresh_token, + }, withCredentials: true }); /** user api相关请求白名单 */ diff --git a/vite.config.ts b/vite.config.ts index dca6ada..aacfe7c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -38,10 +38,10 @@ export default (config: any) => { }, proxy: { // 配置跨域代理 - '/official': { - target: 'http://222.20.126.217:9527', // 目标服务器地址 + '/gateway': { + target: 'http://223.76.236.155:20011', // 目标服务器地址 changeOrigin: true, // 允许跨域 - rewrite: (path) => path.replace(/^\/official/, '/official'), // 重写路径 + rewrite: (path) => path.replace(/^\/gateway/, '/gateway'), // 重写路径 } } },