I know that if I change the proxy setting of my browser to use an HTTP forward proxy, it will issue HTTP CONNECT requests to the proxy server. But this kind of behavior is transparent to the frontend JavaScript code.
Out of pure curiosity, I'm wondering if one can do it on the client side JavaScript level. Is that even possible?
Chrome console:
fetch("https://example.com", {method: 'CONNECT'})
Error message:
PromiseĀ {: TypeError: Failed to execute 'fetch' on 'Window': 'CONNECT' HTTP method is unsupported.
I don't expect this request to return any meaningful response of couse. What surprises me is that the browser doesn't even allow the request to be sent.
No. The fetch specification lists
CONNECT
as a forbidden method as it can be used as part of a security exploit.