Fix JavaScript issues with TLS and/or non-default ports.