node-fetch responding with 503 where request responding with 200 behind proxy

264
December 08, 2017, at 10:35 AM

Below I have two http requests, one made with request and the other being made with isomorphic-fetch (node-fetch). For some reason the request with request works, however node-fetch is responding back with an error code 503. Is there anything I am missing from the fetch version?

const URL = require('url')
const fetch = require('isomorphic-fetch')
const HttpsProxyAgent = require('https-proxy-agent')
const request = require('request');
const url = process.env.URL
const proxy = process.env.PROXY
const requestPromise = function (url, options) {
    if (/^\/\//.test(url)) {
    url = 'https:' + url;
    }
    return new Promise(function(resolve, reject) {
        return request.call(this, url, options, function (err, res, body) {
            if (err) {
            throw new Error(err);
            }
            res.ok = true;
            res.json = function () {
            return JSON.parse(res.body);
            }
            return resolve(res);
        });
    });
};
function getProxy (url) {
    const parsedProxyURL = URL.parse(url);
    parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
    return parsedProxyURL
}
requestPromise(url, {
    agent:new HttpsProxyAgent(getProxy(proxy))
})
    .then(console.log)
    .catch(console.log)

fetch(url, {
    agent:new HttpsProxyAgent(getProxy(proxy))
})
    .then(console.log)
    .catch(console.log)
Rent Charter Buses Company
READ ALSO
Node.js Only allow asset to pass through specific webpage

Node.js Only allow asset to pass through specific webpage

In my current Express Nodejs file , I have this bit of simple code:

204
Stub Mongoose find method

Stub Mongoose find method

I'm trying to stub the find or exec functions to test the following function:

254
Why changeResourceRecordSets gets not authorized to access this resource?

Why changeResourceRecordSets gets not authorized to access this resource?

I'm trying to create a new record in Route 53 of type Alias to tell Route 53 to sue CloudFront to serve the siteI'm trying to do this using the following code:

270
Any one was able successfully Skip group in Nightwatch?

Any one was able successfully Skip group in Nightwatch?

I'm using Nightwatch for UI automation and have difficulties to run successfully skipgroup tagBut grouping works perfectly

163