markdown-link-check
markdown-link-check copied to clipboard
Allow customising User-Agent in request
In our case some internal sites disallow outdated versions of browsers due to security. The affected sites returned 403 in these cases.
I was able to monkey patch that in the link-check library (v4.5.4) by simply replacing the User Agent HTTP header in the lib/proto/http.js file inside my local node_modules with the following string:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
I am raising this issue here, since it seems like in [email protected] the user agent seems to be configurable. Would it be possible to upgrade markdown-link-check to that version and expose that option?
I workaround it by using the following config for now:
httpHeaders: [
{
urls: ["http", ".", "/"],
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36",
},
},
],
This works because markdown-link-check uses startWith to match the urls-array
Though I'd prefer if I can set the Http Agent globally for every address without using the hacky urls: ["http", ".", "/"],