Skip to content

Commit

Permalink
Infrastructure: Include user-agent in link-checker to avoid errors wh…
Browse files Browse the repository at this point in the history
…en servers require it (#2932)
  • Loading branch information
alflennik authored Feb 13, 2024
1 parent 5446c67 commit e032502
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/link-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@ async function checkLinks() {

const getPageData = async () => {
try {
const response = await fetch(externalPageLink);
const response = await fetch(externalPageLink, {
headers: {
// Spoof a normal looking User-Agent to keep the servers happy
// See https://github.com/JustinBeckwith/linkinator/blob/main/src/index.ts
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
},
});
const text = await response.text();
const html = HTMLParser.parse(text);
const ids = html
Expand Down

0 comments on commit e032502

Please sign in to comment.