axios请求https网站报错Unable to verify the first certificate
axios请求https网站报错Unable to verify the first certificate
今天在使用axios出现了一个错误Unable to verify the first certificate,就感觉是证书的问题,自己手动在浏览器中输入https的网站没问题啊,但是在用axios请求的时候还是出问题了,最后之后看看能不能屏蔽掉这个检测了。
可以采用下列任意一个方法解决
- 方法一:直接使用忽略了ssl检测的axios实例
const https = require("https");
const axios = require("axios");
const ignoreSSLAxios = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
});
ignoreSSLAxios.get("http://example.com/getData.do", { httpsAgent: agent }).then((res) => res.data);
以后直接用实例ignoreSSLAxios
发送请求了
- 方法二:单次请求的时候忽略ssl检测
// 在 axios 请求时,选择性忽略 SSL
const https = require("https");
const axios = require("axios");
const agent = new https.Agent({
rejectUnauthorized: false,
});
axios.get("http://example.com/getData.do", { httpsAgent: agent }).then((res) => res.data);
- 分类:
- Web前端
相关文章
amh.sh免费泛域名https证书 自动续期
自己的网站一直使用的https,用ssl证书就是在腾讯云免费申请的,有限期一年,过期了可以再次申请。腾讯云说是有50个免费名额,个人觉得还是够用的。 要说缺点的话也是有的 不能自 阅读更多…
道招网正式开启https
之前我只是对微信小程序好奇,搞了个子域名 https://w.daozhao.com,现在发现越来越多的场景需要https,加上现在的主机貌似只支持一个域名用ssl证书,单独买个多域名ssl证书比较贵 阅读更多…
使用app的华为应用内支付服务还是小心为上,2023年了还有人在支付场景使用http。。。
近期查看邮件的时候发现华为开发者联盟发的一封邮件,大致意思就是出于安全考虑,将于2023年10月1日全面限制应用内支付服务使用HTTP回调地址了。 众所周知HTTP协议以明文方式发送内容,不提供 阅读更多…
GraphQL学习、踩坑记录(三)
在使用了GraphiQL后,我们可以看到这样的页面 从chrome的network里面可以看到传递的参数是这样的 我们在这里可以很方便的使用Query,但是这一般只是测 阅读更多…
nginx开启https parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf
安装nginx,一般是安装在/usr/local/nginx nginx基本操作 cd /usr/local/nginx/sbin 启动 ./nginx 关闭 ./ngin 阅读更多…
curl获取https开头的url的内容
平时我们用curl一般都获取http页面的内容,代码如下 $theurl= "http://www.xx.com"; $_data = array( 'clie 阅读更多…