Go's standard DefaultTransport sets Proxy to ProxyFromEnvironment. A separately constructed &http.Transport{} has a nil Proxy function, which selects no proxy.

That difference can appear after adding a transport just to change a timeout. With the standard default still installed, clone it and change the field you need:

transport := http.DefaultTransport.(*http.Transport).Clone()
transport.ResponseHeaderTimeout = 15 * time.Second

client := &http.Client{
    Transport: transport,
    Timeout: 30 * time.Second,
}

The clone preserves environment proxy selection and the other default transport settings. The type assertion assumes the application has not replaced DefaultTransport with another RoundTripper.

For a transport intentionally built from scratch, set Proxy: http.ProxyFromEnvironment explicitly when that is its routing policy. An explicit ProxyURL function expresses a different policy: one selected intermediary.

Configure the transport before concurrent requests use it, then reuse it for the workload. Changing a shared default object can affect unrelated clients.

Custom TLS settings are separate. Disabling certificate verification is not required to retain proxy discovery, and it would change the security of every matching HTTPS request.

Allakkat attuumassuteqartut