We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请求某一个接口,然后后期可能换接口了。 如何转发接口呢? 解决该问题呢,可以用服务端来进行请求该接口,然后把返回值原封不动的返回即可。
下面是使用 NodeJs + Express 来实现转发Ajax请求的代码
var express = require('express'); var router = express.Router(); var request = require('request'); /** * NodeJs 转发 接口请求 * 使用方式:127.0.0.1:23018/request?url=完整的接口地址 */ router.get('/', function (req, res, next) { req.pipe(request.get(req.query.url, { query: req.query, form: req.body })).pipe(res); }); module.exports = router;
The text was updated successfully, but these errors were encountered:
这个转发http请求,只是把 访问 A 地址的接口, 转到 去请求 B接口
Sorry, something went wrong.
Node转发请求,解决跨域问题, 可以看这个类库 node-http-proxy
No branches or pull requests
下面是使用 NodeJs + Express 来实现转发Ajax请求的代码
The text was updated successfully, but these errors were encountered: