node后台fetch请求数据-Hostname/IP doesn't match certificate's altnames解决方法

 

   一、问题背景

     基于express框架,node后台fetch请求数据,报错Hostname/IP doesn't match certificate's altnames。。。。。

require('isomorphic-fetch');

fetch(url)

二 、两种方式解决。

  1、设置rejectUnauthorized:false

const https = require("https");

const options = {
  agent: new https.Agent({
    rejectUnauthorized: false
  })
};

fetch(url, options)

  2、当前服务器hosts 文件设置


// hosts文件配置
10.x.x.x  api.weixin.qq.com



// 之前访问的URL为,那么就对应到了10.x.x.x的服务器转发了
fetch('api.weixin.qq.com/getticket/xxxxx')

// 如果10.x.x.x代理服务器有端口号8090,那么fetch地址也要加上端口号8090

fetch('api.weixin.qq.com:8090/getticket/xxxxx')

  

 

转载于:https://www.cnblogs.com/ldld/p/10826012.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值