西藏巴青项目

vite.config.js 724B

1234567891011121314151617181920212223242526
  1. import { defineConfig, loadEnv } from 'vite'
  2. import uni from '@dcloudio/vite-plugin-uni'
  3. /**
  4. * uni-app Vue3 H5 开发代理
  5. * - /dev-api → 若依后端(.env.development 的 VITE_APP_API_HOST)
  6. */
  7. export default defineConfig(({ mode }) => {
  8. const env = loadEnv(mode, process.cwd(), '')
  9. const devApiTarget = String(env.VITE_APP_API_HOST || 'http://192.168.1.6:8010').replace(/\/$/, '')
  10. const devApiPrefix = String(env.VITE_APP_BASE_API || '/dev-api')
  11. return {
  12. plugins: [uni()],
  13. server: {
  14. proxy: {
  15. [devApiPrefix]: {
  16. target: devApiTarget,
  17. changeOrigin: true,
  18. rewrite: (path) => path.replace(new RegExp(`^${devApiPrefix}`), '')
  19. }
  20. }
  21. }
  22. }
  23. })