I am using React for frontend
and Python Flask for backend
- I am a beginner in React.
I have setup React with a setupProxy
; both the react server & flask server are setup in HTTPS
with CA signed certificates
my http-proxy-middleware configuration is as below
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
app.use( proxy( '/api/**', { target: 'https://example.com:5000/', logLevel: 'debug', changeOrigin: true } ));
}
when I call the api /api/login from react it should go to https://example.com:5000/api/login However, this call is sent to https://localhost:5000/api/login
the certificates available here pertain to example.com and I get the following error
[HPM] Error occurred while trying to proxy request /api/login from mydomain.com to https://localhost:5000 (ERR_TLS_CERT_ALTNAME_INVALID) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Both React & Flask servers are on the same server for now
how can I configure http-proxy-middleware correctly so that I am reaching example.com:5000 instead of localhost:5000?
2020-08-24 I have done the following and still could not get it to work
- Define a new dns name for the same machine and redirect flask to the new name
- Changed the hostname of the machine
how & where & why does the middleware proxy change example.com to localhost is still a mystery