Proxy issue with auth0 npm package version 4.0.1
theshubhamshivhare opened this issue · 2 comments
Checklist
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
I am trying to use the auth0 NPM package v4.0.1 to export users from Auth0. However, I am encountering a proxy issue that prevents me from doing so. The issue only occurs when I use the latest version of the auth0 npm package (v4.0.1) and when I have VPN enabled. When I turn off the VPN, the issue is resolved. However, this is not a desirable solution as I want to use the latest version of the auth0 NPM package and keep our VPN on for security reasons.
I have tried to update my code to use httpsAgent, but it did not work either. I am still looking for other ways to fix the proxy issue with auth0 NPM package 4.0.1 and VPN.
The code is given below for your reference.
var ManagementClient = require('auth0').ManagementClient;
// import { HttpsProxyAgent } from 'https-proxy-agent';
var { HttpsProxyAgent } = require('https-proxy-agent')
var endpointProxy = 'http://genproxy:8080'
var agent = new HttpsProxyAgent(endpointProxy);
function backup() {
var management = new ManagementClient({
domain: '',
clientId: '',
clientSecret: '',
agent: agent
});
var params = {
name: ''
};
management.connections.getAll(params).then(data => {
console.log(data)
}).catch(err => {
console.log(err)
})
}
backup()
The image below shows the error that occurred.
I would appreciate any guidance you can provide.
Reproduction
I have done the following steps:
a) installed the auth0 v4.0.1 NPM package,
b) coded to obtain the Auth0 Database Connection ID, and
c) encountered a proxy issue that caused failure.
Additional context
No response
node-auth0 version
4.0.1
Node.js version
18.18.0
Hi @theshubhamshivhare - native fetch doesn't support the https-proxy-agent
package yet.
You'll need to use something like node-fetch
for this to work, eg
var ManagementClient = require('auth0').ManagementClient;
var { HttpsProxyAgent } = require('https-proxy-agent')
var endpointProxy = 'http://genproxy:8080'
var agent = new HttpsProxyAgent(endpointProxy);
var nodeFetch = require('node-fetch'); // <= using v2 for cjs import
function backup() {
var management = new ManagementClient({
domain: '',
clientId: '',
clientSecret: '',
agent: agent,
fetch: nodeFetch // <= customize the SDK to use node-fetch instead of native
});
var params = {
name: ''
};
management.connections.getAll(params).then(data => {
console.log(data)
}).catch(err => {
console.log(err)
})
}
backup()
Closing as I believe #955 (comment) answers your question