1

I am trying to set up a proxy on my express app to pass GET requests from http://www.example.com/blog to http://example.news .

I have used the following article to set it up Using nodejs server with request package and function pipe()?

So my code looks like this:

app.use('/blog', function(req, res) {
    var url = "http://example.news" + req.url;
    var options={url:url,timeout: 12000};
    request(options,function (err,preq,pres){
        if(err) res.redirect(url);
    }).pipe(res);
});

If there is an error, I redirect to the actual website.

It is working fine but The problem is I often get h13 connection error when I do the following:

var url = "https://example.news" + req.url;

The exact errors are:

{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

These errors mostly happen when the server first starts but it happens randomly. Does anybody know the proper configuration to proxy a secure server with express and request? and why I get theses errors.

Community
  • 1
  • 1
Cyril Gaillard
  • 909
  • 9
  • 28

0 Answers0