Axios, https and self-signed certificates
See original GitHub issueHi, I’m using axios from vue typescript over https to a web api that returns a self signed cert, but I can’t get axios to ignore cert errors that are then reported by the browser. I have tried suggestions from other posts (that have now been closed) as follows below but just get cert errors reported in the console and nothing on the page until I accept the cert from the console (chrome and FF, Edge won’t do anything and needs Fiddler).
Here is the a snippet from main.ts…
axios.interceptors.request.use((config) => {
const https = require('https');
// https.globalAgent.options.rejectUnauthorized = false; // doesn't work, options is undefined.
config.httpsAgent = new https.Agent({ rejectUnauthorised: false });
config.baseURL = 'https://addr/';
return config;
},
(err) =>
{
console.log('AXIOS Interceptor: Error returned: ' + err);
});
This is from home.vue because the main,ts interceptor code doesn’t work…
async getInfo(siteCode: string): Promise<any> {
const infoEndpoint = 'site-by-code/' + siteCode;
const https = require('https');
try
{
const agent = new https.Agent({
rejectUnauthorized: false,
});
const response = await this.$http.get(this.serviceBase + infoEndpoint, { httpsAgent: agent });
return response.data;
} catch (err) {
console.log(err);
}
return null;
},
Cheers.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How to configure axios to use SSL certificate? - Stack Overflow
Axios is an http(s) client and http clients usually participate in TLS ... If the service has a private SSL cert (self signed...
Read more >How to ignore SSL issues #535 - axios/axios - GitHub
Actually, I find that it does work, but it specifically addresses self-signed certificates. It does not allow expired or invalid certificates.
Read more >Axios & Proxy Manager - Error: self signed certificate ... - Reddit
I'm trying to fetch an URL body using Axios and Brightdata as a proxy (via proxy-manager hosted locally). const axios = require('axios'); const ......
Read more >Securely Connecting Node.js and Axios (JS) Using Mutual TLS
A Complete Guide to Securely Connecting Node.js and Axios (JS) Using ... In your https server, specify the location of your CA root...
Read more >Connect to API's in enterprise closed network using axios in ...
This is the solution that let me consume intranet APIs for self-hosted tools You probably use every day. First create httpsAgent that will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your replies. This was exactly what I was expecting and it helps me to clarify things.
I doubt we should be removing the need to validate SSL or have a bypass for this. When developing locally and using a self-signed certificate you would only need to add this certificate to the browser once and it will be remembered for all future requests.
Should you be using a self-signed certificate on your web host I would suggest you look into a good free SSL provider, else your users will also need to whitelist the SSL certificate. Either way, this is not an Axios issue.