鍍金池/ 問答/HTML/ Vue cli proxy tables能否設(shè)置多個代理?

Vue cli proxy tables能否設(shè)置多個代理?

現(xiàn)在有個問題
就是我們項目開發(fā)的時候是用的是a服務(wù)
因為跨域原因我用vue cli 的proxy tables進行代理訪問a服務(wù)
接著因為兩個項目需要結(jié)合,又要去訪問b服務(wù)
現(xiàn)在是通過a服務(wù)去請求b服務(wù)的方式,可是覺得很麻煩
有什么其他方法可以同時訪問兩個服務(wù)呢?

回答
編輯回答
青黛色

config index.js中設(shè)置

    proxyTable: {
      '/api': {
        target: 'url',
        changeOrigin: true,
        pathRewrite: {
          '^/api': 'api'
        }
      },
      '/img': {
        target: imgUrl,
        changeOrigin: true,
        pathRewrite: {
          '^/img': 'img'
        }
      }
    }
2017年9月30日 05:41
編輯回答
陌上花

proxyTable里直接添加

2018年2月12日 06:46
編輯回答
淡墨

可以的,直接在對象里添加鍵值就行

2017年12月11日 16:31