Vue-cli3配置url請求代理

版本不一樣可能配置的參數也不一樣

$ npx vue -V
@vue/cli 4.2.3

修改 配置文件 vue.config.js

devServer: {
    port: port,
    open: true,
   
    proxy: {
      "/api": {
        target: "https://www.baidu.cn", //跨域網址
        secure: true, // 如果是https接口,需要配置這個參數
        changeOrigin: true, //自動修改http header裏面的host
        pathRewrite: {
          "^/api": "", //路徑的替換規則
        }
      }
    }
  }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章