vite.config.ts 代理两个server

2024-03-24  本文已影响0人  糖醋里脊120625
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({
      script: {
        defineModel: true,
      },
    }),
  ],
  resolve: {
    // 配置路径别名
  },
  server: {
    proxy: {
      "/supplychain-apis": {
        // 匹配请求路径,
        target: "https://nginx.etmobile.net/", // 代理的目标地址
        // 开发模式,默认的127.0.0.1,开启后代理服务会把origin修改为目标地址
        changeOrigin: true,
        // secure: true, // 是否https接口
        // ws: true, // 是否代理websockets

        // 路径重写,**** 如果你的后端有统一前缀(如:/api),就不开启;没有就开启
        //简单来说,就是是否改路径 加某些东西
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
      '/api': {
        target: 'http://api.uomg.com/',
        changeOrigin: true,
        ws:false
      }
    },
  },
});

上一篇 下一篇

猜你喜欢

热点阅读