我有一个带有node-http-proxy的简单反向代理,我想用它来转发来自我前端的REST请求。
只要目标是http,它就可以正常运行,但是当目标是https节点崩溃时! (我的服务器不是https)
let express = require('express');
let app = express();
let httpProxy = require('http-proxy');
let cookieParser = require('cookie-parser');
let apiProxy = httpProxy.createProxyServer();
app.use(cookieParser());
app.all("/*", function(req, res) {
let server = 'https://www.example.com'; // forward requests to this address
apiProxy.web(req, res, {target: server});
});
app.listen(3000, function() {
console.log('Proxy running on port 3000');
});
错误:主机名/ IP与证书的altnames不匹配:“主机: 本地主机。不在证书的altnames中:DNS:*。example.com, DNS:example.com“
我是否可以通过这种方式获取http到https请求以使用node-http-proxy而无需更改目标服务器上的任何CORS参数?