我有一个使用create-react-app生成的React应用。在package.json文件中我有
"proxy": {
"/auth/google": {
"target": "https://localhost:8008"
},
"/api/*": {
"target": "https://localhost:8008"
}
},
应用运行正常,直到我拨打上述代理网址之一。然后我在那里得到例如
Proxy error: Could not proxy request /auth/google from localhost:3000 to https://localhost:8008 (DEPTH_ZERO_SELF_SIGNED_CERT).
我用这些命令生成证书
openssl genrsa -out localhost.key 2048
openssl req -new -x509 -key localhost.key -out localhost.cert -days 3650 -subj /CN=localhost
在我的Node.js应用程序中,我使用以下证书
sslOptions = {
key: fs.readFileSync('./config/localhost.key'),
cert: fs.readFileSync('./config/localhost.cert'),
requestCert: false,
rejectUnauthorized: false
};
https.createServer(sslOptions, app).listen(PORT, () => {
console.log(serverStartMessage);
});
知道如何让这个工作吗?