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 c8019c4 commit ffc95d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build/config/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { createServiceConfig } from '../../src/utils/service';
*
* @param env - The current env
*/
export function createViteProxy(env: Env.ImportMeta) {
const isEnableHttpProxy = env.DEV && env.VITE_HTTP_PROXY === 'Y';
export function createViteProxy(env: Env.ImportMeta, isDev: boolean) {
const isEnableHttpProxy = isDev && env.VITE_HTTP_PROXY === 'Y';

if (!isEnableHttpProxy) return undefined;

Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { setupVitePlugins } from './build/plugins';
import { createViteProxy } from './build/config';

export default defineConfig(configEnv => {
console.log('configEnv: ', configEnv);
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta;

const buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
Expand Down Expand Up @@ -33,7 +34,7 @@ export default defineConfig(configEnv => {
host: '0.0.0.0',
port: 9527,
open: true,
proxy: createViteProxy(viteEnv),
proxy: createViteProxy(viteEnv, configEnv.command === 'serve'),
fs: {
cachedChecks: false
}
Expand Down

0 comments on commit ffc95d2

Please sign in to comment.