commit e2bed95fda636e26d591fd24cf4efa267e392a80
parent 31a70d3181fe5907f5bcd2872ee1f0a0184d23ee
Author: mtmn <miro@haravara.org>
Date: Thu, 23 Apr 2026 00:24:09 +0200
fix: add user-agent headers to fetchers
Diffstat:
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/Cover.purs b/src/Cover.purs
@@ -70,7 +70,8 @@ fetchLastfmCoverUrl cfg artist release = case cfg.lastfmApiKey of
<> "&format=json&api_key="
<> k
Log.info $ "Searching Last.fm for: " <> artist <> " - " <> release
- result <- try $ fetch searchUrl { method: GET }
+ let headers = { "User-Agent": "corpus/1.0 (+https://github.com/mtmn/corpus)" }
+ result <- try $ fetch searchUrl { method: GET, headers }
case result of
Right fr | fr.status == 200 -> do
json <- fromJson fr.json
@@ -205,8 +206,8 @@ serveCover serveNotFound cfg slug url res = do
avifBuf <- liftEffect $ fromArrayBuffer avifAb
uploadResult <- try $ uploadToS3 s3cfg s3Key avifBuf "image/avif"
case uploadResult of
- Right _ -> Log.info $ "Cached to S3: " <> s3Key
- Left err -> Log.error $ "S3 upload FAILED for " <> s3Key <> ": " <> Exception.message err
+ Right _ -> Log.info $ "Uploaded " <> s3Key
+ Left err -> Log.error $ "Failed to upload " <> s3Key <> ": " <> Exception.message err
Right fr ->
Log.warn $ "Background fetch failed for " <> urlStr <> " with status " <> show fr.status
Left err ->
diff --git a/src/Sync.purs b/src/Sync.purs
@@ -88,7 +88,8 @@ fetchLastfmPage apiKey lfmUser page mTo = withRetry "Last.fm fetch" do
<> show page
<> toParam
url = baseUrl <> "&api_key=" <> apiKey
- fr <- fetch url { method: GET }
+ let headers = { "User-Agent": "corpus/1.0 (+https://github.com/mtmn/corpus)" }
+ fr <- fetch url { method: GET, headers }
if fr.status == 200 then do
json <- fromJson fr.json
case parseLastfmResponse json of