Setting HTTPS_PROXY environment breaks proxying

If you are running inside the environment with the HTTPS_PROXY env configured, it breaks how the axios is setting the proxying mechanism. As result, the library is not sending HTTP CONNECT to the proxy and the proxy replies with 'Method Not Allowed' error response.

I was able to solve this by tuning the purecloud-platform-client-v2 library and setting the axios config option proxy to false.

How to reproduce the issue :

const platformClient = require('purecloud-platform-client-v2');
const { HttpsProxyAgent } = require('hpagent');

const clientId = '';
const clientSecret = '';
const proxy = 'http://1.2.3.4:3128';

const agent = new HttpsProxyAgent({
    keepAlive: true,
    keepAliveMsecs: 1000,
    maxSockets: 256,
    maxFreeSockets: 256,
    proxy,
});

console.log(process.env.HTTPS_PROXY);

const client = platformClient.ApiClient.instance;
client.setProxyAgent(agent);
client.setEnvironment('mypurecloud.de');

(async() => {
    try {
        const authResponse = await client.loginClientCredentialsGrant(
            clientId,
            clientSecret
        );
        console.log(authResponse);
    } catch (error) {
        console.error(error);
    }
})();

and run it as below:

HTTPS_PROXY="http://1.2.3.4:3128" node genesys-auth-test.js

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.