-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Description
This request works with the https library:
const options = {
hostname: 'baseurl.com',
path: '/accounts',
method: 'GET',
ca: fs.readFileSync(`${path}CA.pem`),
cert: fs.readFileSync(`${path}CERT.pem`),
key: fs.readFileSync(`${path}KEY.pem`),
auth: 'user:password',
rejectUnauthorized: false
};
const req = https.request(options, (res) => {
res.on('data', (data) => {
process.stdout.write(data);
});
});
req.end();
req.on('error', (e) => {
console.error(e);
});
but this seemingly equivalent request does not work using Axios:
const instance = axios.create({
baseURL: 'https://baseurl.com',
httpsAgent: new https.Agent({
ca: fs.readFileSync(`${path}CA.pem`),
cert: fs.readFileSync(`${path}CERT.pem`),
key: fs.readFileSync(`${path}KEY.pem`),
auth: 'user:password',
rejectUnauthorized: false
})
});
instance.get('/accounts')
.then(_ => console.log(`response: ${_}`))
.catch(err => console.log(`error: ${err.stack}`));
Instead it throws this error:
error: Error: write EPROTO
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at WriteWrap.afterWrite (net.js:763:14)
I've tried these variations of base url but no luck:
- 'https://baseurl.com:443'
- 'baseurl.com'
- 'baseurl.com:443'
any help much appreciated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels