我正在尝试使用axios在我的React应用程序中调用API。该API通过自签名证书的HTTPS进行工作。目前,当连接时,我收到以下错误:
net::ERR_INSECURE_RESPONSE
bundle.js:65253 HTTP Failure in Axios Error: Network Error
at createError (bundle.js:2188)
at XMLHttpRequest.handleError (bundle.js:1717)
我尝试了下面的方法,但没有成功:
import axios from 'axios';
const https = require('https');
const agent = new https.Agent({
rejectUnauthorized: false,
});
const client = axios.create({ //all axios can be used, shown in axios documentation
baseURL: process.env.REACT_APP_API_URL,
responseType: 'json',
withCredentials: true,
httpsAgent: agent
});
export default client;
有没有办法禁用证书验证?