Skip to content

Commit

Permalink
Merge pull request GEOLYTIX#1702 from RobAndrewHurst/cloudfront_fetch
Browse files Browse the repository at this point in the history
Update Cloudfront Provider to Support Node.js Native Fetch API Buffer Handling
  • Loading branch information
RobAndrewHurst authored Nov 12, 2024
2 parents c8dc60c + 13c605c commit 2e1f3b0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mod/provider/cloudfront.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ module.exports = async function cloudfront(ref) {
}

const response = await fetch(signedURL)

logger(`${response.status} - ${url}`, 'cloudfront')

if (response.status >= 300) return new Error(`${response.status} ${ref}`)

if (url.match(/\.json$/i)) return await response.json()

if (ref.params?.buffer) return await response.buffer()
if (ref.params?.buffer) {
const arrayBuffer = await response.arrayBuffer()
return Buffer.from(arrayBuffer)
}

return await response.text()

Expand Down

0 comments on commit 2e1f3b0

Please sign in to comment.