How can I proxy to a ssl endpoint with the webpack-dev-server proxy
target: 'https://example.com:80',
It is very unlikely that port 80 is used for HTTPS. Usually port 443 is used
SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:794:)
It is very likely that the server at port 80 did not reply with HTTPS but with some HTTP error because the message from the client was the start of a TLS handshake and not the expected HTTP request. But the client expected the reply to the TLS handshake and not a HTTP error. That's why you get this error.
Without the proxy : fetch('https://example.com/rpc' ... the SSL request works fine.
That's because you use in this case https://example.com
and not https://example.com:80
. Because you don't give an explicit port it will use the default port for https, i.e. 443.
While I am using the correct config with changeOrigin: true
etc., but still meet 301 and option request, and can't reach the real backend server. Till I try to clean the browser cache, it works correctly.