I have a simple reverse proxy with node-http-proxy that I want to use to just forward REST requests from my front-end.
It works fine as long as the target is http, but when the target is https node crashes! (My server is not 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');
});
Error: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:*.example.com, DNS:example.com"
Can I get http to https requests to work with node-http-proxy in this way without changing any CORS parameters on the target server?
via mottosson
No comments:
Post a Comment