Skip to content

Commit

Permalink
Corrected the Referer value.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDalek committed Feb 20, 2025
1 parent 97b59b7 commit 553669b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.esm.js.map

Large diffs are not rendered by default.

47 changes: 27 additions & 20 deletions lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,36 @@ async function fetch(url, requestOptions = {}) {
const protocol = getProtocol(url);

protocol
.get(url, Object.assign({
headers: {
'User-Agent': 'highcharts/export',
'Referer': 'highcharts.export'
}
}, requestOptions || {}), (res) => {
let data = '';
.get(
url,
Object.assign(
{
headers: {
'User-Agent': 'highcharts/export',
Referer: 'highcharts/export'
}
},
requestOptions || {}
),
(res) => {
let data = '';

// A chunk of data has been received.
res.on('data', (chunk) => {
data += chunk;
});
// A chunk of data has been received.
res.on('data', (chunk) => {
data += chunk;
});

// The whole response has been received.
res.on('end', () => {
if (!data) {
reject('Nothing was fetched from the URL.');
}
// The whole response has been received.
res.on('end', () => {
if (!data) {
reject('Nothing was fetched from the URL.');
}

res.text = data;
resolve(res);
});
})
res.text = data;
resolve(res);
});
}
)
.on('error', (error) => {
reject(error);
});
Expand Down
6 changes: 1 addition & 5 deletions lib/highcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ export async function triggerExport(chartOptions, options, displayErrors) {
let constr = options.export.constr || 'chart';
constr = typeof Highcharts[constr] !== 'undefined' ? constr : 'chart';

Highcharts[constr](
'container',
finalOptions,
finalCallback
);
Highcharts[constr]('container', finalOptions, finalCallback);

// Get the current global options
const defaultOptions = getOptions();
Expand Down

0 comments on commit 553669b

Please sign in to comment.