When I try to proxy this http://localhost:9000/rpc
request, I receive:
cannot proxy to https://example.appspot.com:80
(write EPROTO 101057795:error:140770FC:SSL routines:
SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:794:)
webpack-dev-derver config:
devServer: {
contentBase: "./",
hostname: 'localhost',
port: 9000,
proxy: {
'/rpc': {
target: 'https://example.appspot.com',
secure: false,
changeOrigin: true // **Update-2 SOLVED**
}
}
}
I use fetch : fetch('/rpc' ...
to make the request and Windows 10 professional to run webpack.
Without the proxy : fetch('https://example.com/rpc' ...
the SSL request works fine.
Update. I had to use the SSL port 443 (see the answer of Steffen).
Now using: https://example.appspot.com:443
But still not working with secure: true
. The console log shows:
cannot proxy to https://example.appspot.com:443
(Hostname/IP doesn't match certificate's altnames: "Host: localhost.
is not in the cert's altnames: DNS:*.appspot.com, DNS:*.thinkwithgoogle.com,
DNS:*.withgoogle.com, DNS:*.withyoutube.com, DNS:appspot.com,
DNS:thinkwithgoogle.com, DNS:withgoogle.com, DNS:withyoutube.com")
And with secure: false
. The console reports: 404 (Not Found)
Update: SOLVED using changeOrigin: true
. Docs here.