Tag: 代理

如何在Express中模拟中间件跳过unit testing的身份validation?

Express中有以下内容 //index.js var service = require('./subscription.service'); var auth = require('../auth/auth.service'); var router = express.Router(); router.post('/sync', auth.isAuthenticated, service.synchronise); module.exports = router; 我想覆盖或模拟isAuthenticated返回这个 auth.isAuthenticated = function(req, res, next) { return next(); } 这是我的unit testing: it('it should return a 200 response', function(done) { //proxyquire here? request(app).post('/subscriptions/sync') .set('Authorization','Bearer '+ authToken) .send({receipt: newSubscriptionReceipt }) .expect(200,done); }); 我试过使用proxyquire嘲笑index.js – 我想我需要存根路由器? 我也尝试在testing中覆盖 […]

在socket.io中使用代理时没有获取远程地址

在我的socket.io代码中, socket.sockets.on('connection', function(client){ var ip = client.handshake.address.address; .. } ip始终返回127.0.0.1,这是因为服务器位于代理之后。 如何正确获取远程地址? 编辑:我正在使用http代理

Javascript:REGEX将所有相关url更改为Absolute

我目前正在创build一个Node.js webscraper /代理,但我无法parsing在源代码的脚本部分find相关的url,我想REGEX会做的伎俩。 虽然我不知道如何实现这一点。 无论如何,我可以去做这件事吗? 此外,我打开这样做的一个更简单的方法,因为我很困惑如何其他代理parsing网站。 我认为大多数只是荣耀的网站刮板,可以读取网站的来源中继所有链接/forms回代理。

节点代理networking套接字如何检查

我使用下面的模块,它适用于反向代理https://github.com/nodejitsu/node-http-proxy目前我已经使用下面的代码示例 httpProxy.createServer({ target: 'ws://localhost:9014', ws: true }).listen(8014); 我的问题是我如何检查/模拟 websockets工作? 任何testing将有帮助…

AngularJS + ExpressJS。 代理POST请求正在等待

使用AngularJS + Express我有以下代码将我的请求代理到远程服务: app.get('/api.json', function (req, res) { req.pipe(request("http://test-api.com/api.json")).pipe(res); }); app.post('/api.json', function (req, res) { req.pipe(request.post("http://test-api.com/api.json")).pipe(res); }); 所有的GET请求工作正常,但POST请求在我的浏览器中挂起。 以下是我的post: $http({ method: 'POST', url: '/api.json', data: $.param({ "title": not.title, "desc": not.description }), // pass in data as strings headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).success(function () {alert("Success");}); 怎么了? 编辑:这是在控制台上看到的请求: 我应该检查什么来提供更多的信息?

Heroku Node.js node-http-proxy模块没有这样的应用程序错误

我试图将stream量从我的testing应用程序的/ api / * urlredirect到Heroku托pipe的我的api。 因此,应将localhost / api / hello代理到testapp.heroku.com/hello,并返回响应。 使用node-http-proxy在localhost到localhost上完美工作,但是当我将它指向myapp.heroku.com时,我得到这个错误: Heroku | No such app There is no app configured at that hostname. Perhaps the app owner has renamed it, or you mistyped the URL. 我感觉Heroku的路由系统正在欺骗我的代理请求,而且我还没有find解决这个问题的方法。 有任何想法吗?

我可以添加cookie到webpack dev服务器代理吗?

我正在尝试在我的webpack dev服务器中设置一个代理。 问题是我不控制我连接的服务器,我需要validation请求。 有没有办法,我可以添加cookie到我发送到代理服务器的请求? 我已经浏览了webpack dev服务器代理服务器页面 ,以及它链接到的node-http-proxy页面,而且我没有看到任何提及的cookie。 我也不确定是否有办法让我看到这些转发的请求,所以我不知道我正在尝试什么是做任何事情。 有任何想法吗?

Node.js http.get

我有以下代码请求Google.com主页,并将页面数据发送回客户端的Iframe。 var options = { host: 'www.google.com', port: 80, path: '/', method: 'GET' }; var req = http.get(options, function(res) { var pageData = ""; res.setEncoding('utf8'); res.on('data', function (chunk) { pageData += chunk; }); res.on('end', function(){ response.send(pageData) }); }); 但是,所有的图像和CSS在iframe中被破坏? 我怎样才能保存图像和CSS?

NPM安装与代理周围的artifactory不工作

所以基本上我试图从https://registry.npmjs.org/使用npm install下载软件包,但是我使用代理。 我已经build立了一个远程仓库,它会使用artifactory(上面的链接)和caching,所以我可以在本地拉,但似乎没有工作。 遵循这些方向: http : //www.jfrog.com/confluence/display/RTF/Npm+Repositories 任何人都有代理经验的困难? 我已经看到很多关于更改configuration设置的post,但这不是我所需要的,我必须遵循artifactory来获得我需要的东西,并且相应地更改了我的configuration设置,以便artifactorybuild议,即npm config set registry 谢谢!

简单的node.js代理通过http服务器http请求

尝试通过制作一个简单的http代理服务器来了解关于node.js的更多信息。 使用场景很简单:用户 – >代理 – >服务器 – >代理 – >用户 下面的代码工作,直到最后一步。 无法findpipe道连接器的输出回到用户的方式。 #!/usr/bin/env node var url = require('url'), http = require('http'), acceptor = http.createServer().listen(3128); acceptor.on('request', function(request, response) { console.log('request ' + request.url); request.pause(); var options = url.parse(request.url); options.headers = request.headers; options.method = request.method; options.agent = false; var connector = http.request(options); request.pipe(connector); request.resume(); // connector.pipe(response); // […]