API: don't re-add /api suffix to grafana.com API URL (#62280)

The old GrafanaComURL setting didn't have the /api suffix so needed it
adding on by the proxy director, but the new GrafanaComAPIURL setting is
assumed to already point directly to the API and doesn't need an
additional suffix.

This is the only place in the codebase that GrafanaComAPIURL is used.
This commit is contained in:
Ben Sully 2023-01-27 09:20:55 +00:00 committed by GitHub
parent f98ad926ac
commit 5ff94e528b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,15 +23,15 @@ var grafanaComProxyTransport = &http.Transport{
TLSHandshakeTimeout: 10 * time.Second, TLSHandshakeTimeout: 10 * time.Second,
} }
func ReverseProxyGnetReq(logger log.Logger, proxyPath string, version string, grafanaComUrl string) *httputil.ReverseProxy { func ReverseProxyGnetReq(logger log.Logger, proxyPath string, version string, grafanaComAPIUrl string) *httputil.ReverseProxy {
url, _ := url.Parse(grafanaComUrl) url, _ := url.Parse(grafanaComAPIUrl)
director := func(req *http.Request) { director := func(req *http.Request) {
req.URL.Scheme = url.Scheme req.URL.Scheme = url.Scheme
req.URL.Host = url.Host req.URL.Host = url.Host
req.Host = url.Host req.Host = url.Host
req.URL.Path = util.JoinURLFragments(url.Path+"/api", proxyPath) req.URL.Path = util.JoinURLFragments(url.Path, proxyPath)
// clear cookie headers // clear cookie headers
req.Header.Del("Cookie") req.Header.Del("Cookie")