vite.config.js 620 B

123456789101112131415161718192021
  1. import { defineConfig } from "vite";
  2. import uni from "@dcloudio/vite-plugin-uni";
  3. // H5 dev: 通过 Vite 代理把 /api 转发到后端,避开浏览器 CORS。
  4. // 接入新后端时,把 API_TARGET 改成对应环境即可。
  5. // const API_TARGET = 'http://aiot.zoomwin.com.cn:51001/api'
  6. const API_TARGET = "http://192.168.1.147:18086";
  7. // const API_TARGET = "http://192.168.1.102:18086";
  8. export default defineConfig({
  9. plugins: [uni()],
  10. server: {
  11. proxy: {
  12. "/api": {
  13. target: API_TARGET,
  14. changeOrigin: true,
  15. rewrite: (path) => path.replace(/^\/api/, ''),
  16. },
  17. },
  18. },
  19. });