From 4e707823f65ecebec037f80ff6ec4497c00ad74e Mon Sep 17 00:00:00 2001 From: alflennik Date: Tue, 13 Feb 2024 16:59:23 -0500 Subject: [PATCH] Issue 2907 fix link checker by spoofing user-agent --- scripts/link-checker.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/link-checker.js b/scripts/link-checker.js index aee378ff9c..3e6b8859a2 100644 --- a/scripts/link-checker.js +++ b/scripts/link-checker.js @@ -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