From c8019c4ff71dc80a2362ac1c685ffb4ab32f8300 Mon Sep 17 00:00:00 2001 From: Soybean Date: Mon, 4 Mar 2024 12:15:00 +0800 Subject: [PATCH] fix(projects): fix proxy config --- .env.prod | 4 ++-- .env.test | 4 ++-- build/config/proxy.ts | 2 +- src/service/request/index.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.prod b/.env.prod index 5da5eb14..832d4d6c 100644 --- a/.env.prod +++ b/.env.prod @@ -1,7 +1,7 @@ -# http url, prod environment +# backend service base url, prod environment VITE_SERVICE_BASE_URL=https://mock.apifox.com/m1/3109515-0-default -# http other url, prod environment +# other backend service base url, prod environment VITE_OTHER_SERVICE_BASE_URL= `{ "demo": "http://localhost:9529" }` diff --git a/.env.test b/.env.test index 250b4068..0f3c35ce 100644 --- a/.env.test +++ b/.env.test @@ -1,7 +1,7 @@ -# http url, test environment +# backend service base url, test environment VITE_SERVICE_BASE_URL=https://mock.apifox.com/m1/3109515-0-default -# http other url, test environment +# other backend service base url, test environment VITE_OTHER_SERVICE_BASE_URL= `{ "demo": "http://localhost:9528" }` diff --git a/build/config/proxy.ts b/build/config/proxy.ts index e58b018d..a1d9f926 100644 --- a/build/config/proxy.ts +++ b/build/config/proxy.ts @@ -7,7 +7,7 @@ import { createServiceConfig } from '../../src/utils/service'; * @param env - The current env */ export function createViteProxy(env: Env.ImportMeta) { - const isEnableHttpProxy = env.VITE_HTTP_PROXY === 'Y'; + const isEnableHttpProxy = env.DEV && env.VITE_HTTP_PROXY === 'Y'; if (!isEnableHttpProxy) return undefined; diff --git a/src/service/request/index.ts b/src/service/request/index.ts index 2e816826..f4b384a9 100644 --- a/src/service/request/index.ts +++ b/src/service/request/index.ts @@ -2,7 +2,7 @@ import { BACKEND_ERROR_CODE, createFlatRequest, createRequest } from '@sa/axios' import { localStg } from '@/utils/storage'; import { getServiceBaseURL } from '@/utils/service'; -const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'Y'; +const isHttpProxy = import.meta.env.DEV && import.meta.env.VITE_HTTP_PROXY === 'Y'; const { baseURL, otherBaseURL } = getServiceBaseURL(import.meta.env, isHttpProxy); export const request = createFlatRequest(