Skip to content

Commit

Permalink
fix: add user agent to remote images request
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Apollis authored and zbjornson committed Sep 1, 2022
1 parent dce0fd1 commit 3fb4ed9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
* Crashes and hangs when using non-finite values in `context.arc()`. ([#2055](https://github.com/Automattic/node-canvas/issues/2055))
* Incorrect `context.arc()` geometry logic for full ellipses. ([#1808](https://github.com/Automattic/node-canvas/issues/1808), ([#1736](https://github.com/Automattic/node-canvas/issues/1736)))
* Added missing `deregisterAllFonts` to the Typescript declaration file ([#2096](https://github.com/Automattic/node-canvas/pull/2096))
* Add `User-Agent` header when requesting remote images ([#2099](https://github.com/Automattic/node-canvas/issues/2099))

2.9.3
==================
Expand Down
5 changes: 4 additions & 1 deletion lib/image.js
Expand Up @@ -49,7 +49,10 @@ Object.defineProperty(Image.prototype, 'src', {

if (!get) get = require('simple-get')

get.concat(val, (err, res, data) => {
get.concat({
url: val,
headers: { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36' }
}, (err, res, data) => {
if (err) return onerror(err)

if (res.statusCode < 200 || res.statusCode >= 300) {
Expand Down

0 comments on commit 3fb4ed9

Please sign in to comment.