webpack.dev.conf.js文件里
- const express = require('express')
const app = express()
const proxyMiddlewar = require('http-proxy-middleware')
const proxyPath = 'http://api.xxx.com/Api/Diagnosis/GetPestByPlant'
const proxyOption = {target: proxyPath,
changeOrigin: true,
ws: true,
headers:{'referer': 'http://xxxxx/intelligenceDiagnosis',
'Host':'api.xxx.com',
'Origin':'http://xxxxx.com'
}
}
app.use('/', proxyMiddlewar(proxyOption))
A.VUE里
this.axios.post('http://api.xxx.com/Api/',this.qs.stringify({"pageIndex":1,"pageSize":200,"cropName":"枸杞子","search":null,"pestType":"病害"}),
{
headers: {
"Authorization":"Bearer xxxxxxxx",
"erpSourceType":"web",
"Content-Type":"application/json"
}
})
在浏览器里看文件头信息
只有'Host'项改变了, referer与Origin还是本地址
附上http-proxy-middleware
option.headers可选项
3 个回复
DCloud_UNI_GSQ
确保你使用的工具支持伪造referer,否则换个工具,比如使用代理软件:Charles。
2***@qq.com
做好了吗? 我也想要这种 ,,,加群757988036 探讨下
l***@126.com (作者)
没有。放PHP里用CURL做的