Skip to content

Commit e032502

Browse files
authored
Infrastructure: Include user-agent in link-checker to avoid errors when servers require it (#2932)
1 parent 5446c67 commit e032502

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/link-checker.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@ async function checkLinks() {
135135

136136
const getPageData = async () => {
137137
try {
138-
const response = await fetch(externalPageLink);
138+
const response = await fetch(externalPageLink, {
139+
headers: {
140+
// Spoof a normal looking User-Agent to keep the servers happy
141+
// See https://github.com/JustinBeckwith/linkinator/blob/main/src/index.ts
142+
'User-Agent':
143+
'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',
144+
},
145+
});
139146
const text = await response.text();
140147
const html = HTMLParser.parse(text);
141148
const ids = html

0 commit comments

Comments
 (0)