鍍金池/ 問答/HTML/ http-proxy-middleware反向代理問題

http-proxy-middleware反向代理問題

想反向代理的地址為http://huaban.com/?page=2
在nginx的反向代理設(shè)置如下
圖片描述

訪問http://localhost:8099/api?page=2可以正常訪問到數(shù)據(jù)
圖片描述

這個是在node中的反向代理設(shè)置

訪問http://localhost:3300/api?page=2就訪問不到數(shù)據(jù)了,怎么才能正常訪問到數(shù)據(jù)

回答
編輯回答
薄荷綠

因?yàn)樗械恼埱笾苯颖?app.use('/', express.static('static')) 處理了,不會走到下面的 proxy 。

2017年4月18日 03:55
編輯回答
九年囚
app.use(proxy('/api',{
  target: HOST,
  changeOrigin: true,
  pathRewrite: {
    '^/api': ''
  }
}))
2018年6月9日 08:02