Skip to content

Commit d04fe36

Browse files
fix: remove user-agent from sitemap handler (#690)
1 parent d18a8e6 commit d04fe36

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/sitemap/handler.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { createOpportunityData } from './opportunity-data-mapper.js';
3232
const auditType = Audit.AUDIT_TYPES.SITEMAP;
3333
// Add new constant for status codes we want to track
3434
const TRACKED_STATUS_CODES = Object.freeze([301, 302, 404]);
35-
const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
3635

3736
export const ERROR_CODES = Object.freeze({
3837
INVALID_URL: 'INVALID URL',
@@ -67,9 +66,6 @@ const VALID_MIME_TYPES = Object.freeze([
6766
export async function fetchContent(targetUrl) {
6867
const response = await fetch(targetUrl, {
6968
method: 'GET',
70-
headers: {
71-
'User-Agent': DEFAULT_USER_AGENT,
72-
},
7369
});
7470
if (!response.ok) {
7571
throw new Error(`Fetch error for ${targetUrl} Status: ${response.status}`);
@@ -188,9 +184,6 @@ export async function filterValidUrls(urls) {
188184
const response = await fetch(url, {
189185
method: 'HEAD',
190186
redirect: 'manual',
191-
headers: {
192-
'User-Agent': DEFAULT_USER_AGENT,
193-
},
194187
});
195188

196189
if (response.status === 200) {
@@ -205,9 +198,6 @@ export async function filterValidUrls(urls) {
205198
const redirectResponse = await fetch(finalUrl, {
206199
method: 'HEAD',
207200
redirect: 'follow',
208-
headers: {
209-
'User-Agent': DEFAULT_USER_AGENT,
210-
},
211201
});
212202
return {
213203
status: NOT_OK,
@@ -608,7 +598,7 @@ export async function opportunityAndSuggestions(auditUrl, auditData, context) {
608598

609599
export default new AuditBuilder()
610600
.withRunner(sitemapAuditRunner)
611-
.withUrlResolver((site) => composeAuditURL(site.getBaseURL(), DEFAULT_USER_AGENT)
601+
.withUrlResolver((site) => composeAuditURL(site.getBaseURL())
612602
.then((url) => getUrlWithoutPath(prependSchema(url))))
613603
.withPostProcessors([generateSuggestions, opportunityAndSuggestions])
614604
.build();

0 commit comments

Comments
 (0)