我正在尝试使用axios在我的反应应用程序中使用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)
Run Code Online (Sandbox Code Playgroud)
我尝试了以下但没有成功:
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;
Run Code Online (Sandbox Code Playgroud)
有没有办法禁用证书验证?