Skip to content

Commit

Permalink
fix: add headers to crates query
Browse files Browse the repository at this point in the history
Otherwise we are getting denied from cloudfront
  • Loading branch information
yrobla committed Feb 22, 2024
1 parent e4d6c4c commit 7da0231
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/feeds/crates/crates.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ func fetchPackages(baseURL string) ([]*Package, error) {
if err != nil {
return nil, err
}
resp, err := httpClient.Get(pkgURL)

req, err := http.NewRequest("GET", pkgURL, nil)
if err != nil {
return nil, err
}

// set headers
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", "package-feeds")
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
}
Expand All @@ -51,6 +60,7 @@ func fetchPackages(baseURL string) ([]*Package, error) {
if err != nil {
return nil, fmt.Errorf("failed to fetch crates package data: %w", err)
}
fmt.Println(resp)

v := &crates{}
err = json.NewDecoder(resp.Body).Decode(v)
Expand Down

0 comments on commit 7da0231

Please sign in to comment.