zoukankan      html  css  js  c++  java
  • 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')
    

      

  • 相关阅读:
    POJ2960 S-Nim
    HDU1850 Being a Good Boy in Spring Festival
    描述性统计-1
    基础-1
    .Net程序调试
    家装设计
    ACDSee技巧
    Timeline Maker 用法小结
    Windows 7 操作系统核心文件
    艺术字的操作
  • 原文地址:https://www.cnblogs.com/ldld/p/10826012.html
Copyright © 2011-2022 走看看