Skip to content

Commit

Permalink
fix(projects): fix proxy config
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Mar 4, 2024
1 parent b546ff8 commit c8019c4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -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"
}`
4 changes: 2 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
@@ -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"
}`
2 changes: 1 addition & 1 deletion build/config/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/service/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<App.Service.Response>(
Expand Down

0 comments on commit c8019c4

Please sign in to comment.