diff --git a/CHANGELOG.md b/CHANGELOG.md index b6662cc62..886602912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ================== diff --git a/lib/image.js b/lib/image.js index c5b594f8a..4a37849ee 100644 --- a/lib/image.js +++ b/lib/image.js @@ -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) {