Skip to content

Commit 3fb4ed9

Browse files
Antoine Apolliszbjornson
authored andcommitted
fix: add user agent to remote images request
1 parent dce0fd1 commit 3fb4ed9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1818
* Crashes and hangs when using non-finite values in `context.arc()`. ([#2055](https://github.com/Automattic/node-canvas/issues/2055))
1919
* 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)))
2020
* Added missing `deregisterAllFonts` to the Typescript declaration file ([#2096](https://github.com/Automattic/node-canvas/pull/2096))
21+
* Add `User-Agent` header when requesting remote images ([#2099](https://github.com/Automattic/node-canvas/issues/2099))
2122

2223
2.9.3
2324
==================

lib/image.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ Object.defineProperty(Image.prototype, 'src', {
4949

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

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

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

0 commit comments

Comments
 (0)