1.搭建代理映射, 用express和cors(解决跨域问题)
2.做个拦截操作,并用request去请求数据
const express = require('express')
const {
createProxyMiddleware
} = require('http-proxy-middleware')
const path = require('path')
const app = express()
const request = require('request')
const cors = require("cors")
app.use(cors())
app.get("/ImHn/*", function (req, res) {
request({
timeout: 5000, // 设置超时
method: 'GET', //请求方式
headers: {
Cookie: "6817a608-bc22-4c25-b11b-e753b1e29b58"
},
url: 'http://10.158.3.67:8075/ImHn/qua/fetchQuaSelfDefectFy?page=1&rows=12&otherId5=402881c16d3de639016d4300035b005f&otherId4=&otherId3=&_=1596941137570', //url
}, function (error, response, body) {
console.log(body)
res.json(response.body)
});
})
app.listen(8081, () => {})
网友评论