{"record":{"id":"acc4e859996a6af3","repo":"gatsbyjs/gatsby","slug":"plugin-plugin-name-attempted-to-set-request-hea-acc4e8","errorCode":null,"errorMessage":"Plugin ${plugin.name} attempted to set request headers for a domain that is not a valid URL. (${domain})","messagePattern":"Plugin (.+?) attempted to set request headers for a domain that is not a valid URL\\. \\((.+?)\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/redux/actions/public.js","lineNumber":1520,"sourceCode":"    reporter.panic(\n      `Plugin ${plugin.name} attempted to set request headers with invalid arguments. See above warnings for more info.`\n    )\n\n    return null\n  }\n\n  const baseDomain = url.parse(domain)?.hostname\n\n  if (baseDomain) {\n    return {\n      type: `SET_REQUEST_HEADERS`,\n      payload: {\n        domain: baseDomain,\n        headers,\n      },\n    }\n  } else {\n    reporter.panic(\n      `Plugin ${plugin.name} attempted to set request headers for a domain that is not a valid URL. (${domain})`\n    )\n\n    return null\n  }\n}\n\nmodule.exports = { actions }\n","sourceCodeStart":1502,"sourceCodeEnd":1529,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/redux/actions/public.js#L1502-L1529","documentation":"Thrown by setRequestHeaders when `domain` is a string but url.parse(domain).hostname is falsy: the string is not a parseable URL. The action cannot determine the base domain to key the headers on, so it panics with the offending domain value and returns null.","triggerScenarios":"domain is a string but malformed: empty, a bare scheme like 'http://', a string with no hostname (e.g. '/path' or '://'), or whitespace-only.","commonSituations":"Reading domains from config where one entry is empty; constructing domain dynamically (e.g. `${sub}.${base}` with undefined base); passing a path or protocol instead of a host.","solutions":["Pass a fully-qualified URL or hostname string, e.g. 'https://example.com' or 'example.com'.","Validate the domain before calling: ensure new URL(domain) (or url.parse) yields a hostname.","Filter out empty/undefined domain values from config-driven loops."],"exampleFix":"// before\nactions.setRequestHeaders({ domain: rawConfig.url, headers })\n// after\nconst hostname = rawConfig.url && new URL(rawConfig.url).hostname\nif (hostname) actions.setRequestHeaders({ domain: hostname, headers })","handlingStrategy":"validation","validationCode":"let hostname\ntry { hostname = new URL(domain).hostname } catch { hostname = '' }\nif (!hostname) throw new Error(`setRequestHeaders domain is not a valid URL: ${domain}`)\nactions.setRequestHeaders({ domain, headers })","typeGuard":"function isValidDomainUrl(d: string): boolean {\n  try { return Boolean(new URL(d).hostname) } catch { return false }\n}","tryCatchPattern":null,"preventionTips":["Pass full URLs or bare hostnames; validate with new URL(...) first.","Drop empty/undefined domains from config before looping into setRequestHeaders.","Normalize domains to hostnames before calling the action."],"tags":["action","setrequestheaders","url","validation"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}