第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue-cli proxyTable怎么配置

vue-cli proxyTable怎么配置

海綿寶寶撒 2018-11-05 13:17:39
如何實現(xiàn)線上環(huán)境使用setting.host + '/api/sop/',本地dev請求localhost:3000呢?const instance = axios.create({  baseURL: setting.host + '/api/sop/',  timeout: 20000,  headers: {    'Content-Type': 'application/json',    'Accept': 'application/json',  },});config   proxyTable: {  '/api': {     target: "http://127.0.0.1:3000",     changeOrigin: true,     pathRewrite: {      '^/api': ""     }   } },
查看完整描述

1 回答

?
拉風的咖菲貓

TA貢獻1995條經(jīng)驗 獲得超2個贊

用的vue-resource,理論上思路是一樣的。proxyTablenginx的反向代理是一樣的道理,攔截特定的url,轉(zhuǎn)發(fā)到其他服務(wù)器。

// config

proxyTable: {

  '/api': {

    target: 'http://10.0.0.10:8080',

    changeOrigin: true,

    pathRewrite: {

      '^/api': '/api'

    }

  }

}


// code

this.$http.post('/api/login',{

  username: 'xxx',

  password: 'xxx'

}).then((response) => {

  // ...

}, (response) => {

  // ...

});


# 生產(chǎn)環(huán)境 nginx

location /api {

  proxy_pass http://10.0.0.10:8080/api;

}


查看完整回答
反對 回復(fù) 2018-12-10
  • 1 回答
  • 0 關(guān)注
  • 917 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號