Use https for api requests, unless localhost, in which case http.