[英]CERT_HAS_EXPIRED: node.js and https request using create-react-app
我正在使用create-react-app和axios。 在package.json中,代理是通过以下方式配置的:
"proxy": {
"/api-rc": {
"target": "https://www.example.com",
"pathRewrite": {
"^/api-rc": "/api"
}
}
但是我得到这个错误:
Proxy error: Could not proxy request /api/islogged from localhost:3000 to https://www.example.com.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (CERT_HAS_EXPIRED).
我试图通过两种方式解决它:
if(process.env.NODE_ENV === 'development'){
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}
和
export const get = (url, params) =>
const agent = new https.Agent({
rejectUnauthorized: false
});
const p = params ? {httpsAgent: agent, params: {...params}} : {};
return axios.get(url, p)
};
但是错误仍然存在:(
我以这种方式解决了我的问题
"/api-rc": {
"target": "https://www.reportago.com",
"changeOrigin": true,
"secure": false,
"pathRewrite": {
"^/api-rc": "/api"
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.