shuishen
2025-09-28 b4e7fc334e6b1e1844a812ebf6b3924f70dc1b9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * @Author       : yuan
 * @Date         : 2025-09-28 09:31:16
 * @LastEditors  : yuan
 * @LastEditTime : 2025-09-28 09:40:50
 * @FilePath     : \build\config\proxy.js
 * @Description  :
 * Copyright 2025 OBKoro1, All Rights Reserved.
 * 2025-09-28 09:31:16
 */
export const createViteProxy = (env) => {
  const { VITE_APP_PROXY, VITE_API_PREFIX, VITE_API_BASE_URL } = env;
  // 不使用代理直接返回
  if (!JSON.parse(VITE_APP_PROXY)) return undefined;
  const proxy = {
    [VITE_API_PREFIX]: {
      target: VITE_API_BASE_URL,
      changeOrigin: true,
      rewrite: path => path.replace(new RegExp(`^${VITE_API_PREFIX}`), ''),
    },
  };
  return proxy;
};