proxy.ts 382 B

12345678910111213
  1. import type { ProxyOptions } from 'vite';
  2. export const createProxy = (env): Record<string, ProxyOptions> => {
  3. const { VITE_API_BASE_URL, VITE_API_TARGET_URL } = env;
  4. const proxy = {
  5. [VITE_API_BASE_URL]: {
  6. target: VITE_API_TARGET_URL,
  7. changeOrigin: true,
  8. rewrite: path => path.replace(new RegExp(`^${VITE_API_BASE_URL}`), '')
  9. }
  10. };
  11. return proxy;
  12. };