首页 > 解决方案 > https 在本机 axios 中未定义

问题描述

我已经使用 axios 来响应本机应用程序,但是在实现 https.agent 时它显示 https 是未定义的。如何解决这个问题?
我的代码

const instance = axios.create({
  httpsAgent: new https.Agent({
    rejectUnauthorized: false
  })
});

 instance.get('https://example.com');

// At request level
const agent = new https.Agent({
  rejectUnauthorized: false
});
    axios.post('/practz/login', {
          "username" :"orgadmin1@example.com",
          "password":"exam",
          "appId":"AABBCD",
          "domainName":"example.com",
          httpsAgent: agent
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });

标签: reactjsreact-nativehttpsaxios

解决方案


这是 Android 9 或 10 的问题,您必须在 Apache 配置中添加 SSLCertificateChainFile。

SSLCertificateChainFile "/opt/bitnami/apache2/conf/server-ca.crt"

然后它将正常工作


推荐阅读