{"record":{"id":"a51cc5cc81907c2d","repo":"gatsbyjs/gatsby","slug":"could-not-find-the-file-specified-in-the-link-head","errorCode":null,"errorMessage":"Could not find the file specified in the Link header `${header}`.The gatsby-plugin-gatsby-cloud is looking for a matching file (with or without a webpack hash). Check the public folder and your gatsby-config.js to ensure you are pointing to a public file.","messagePattern":"Could not find the file specified in the Link header `(.+?)`\\.The gatsby-plugin-gatsby-cloud is looking for a matching file \\(with or without a webpack hash\\)\\. Check the public folder and your gatsby-config\\.js to ensure you are pointing to a public file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deprecated-packages/gatsby-plugin-gatsby-cloud/src/build-headers-program.js","lineNumber":67,"sourceCode":"  })\n  Object.keys(userHeaders).forEach(path => {\n    if (!merged[path]) {\n      merged[path] = userHeaders[path]\n    }\n  })\n  return merged\n}\n\nfunction transformLink(manifest, publicFolder, pathPrefix) {\n  return header =>\n    header.replace(LINK_REGEX, (__, prefix, file, suffix) => {\n      const hashed = manifest[file]\n      if (hashed) {\n        return `${prefix}${pathPrefix}${hashed}${suffix}`\n      } else if (existsSync(publicFolder(file))) {\n        return `${prefix}${pathPrefix}${file}${suffix}`\n      } else {\n        throw new Error(\n          `Could not find the file specified in the Link header \\`${header}\\`.` +\n            `The gatsby-plugin-gatsby-cloud is looking for a matching file (with or without a ` +\n            `webpack hash). Check the public folder and your gatsby-config.js to ensure you are ` +\n            `pointing to a public file.`\n        )\n      }\n    })\n}\n\n// program methods\n\nconst mapUserLinkHeaders =\n  ({ manifest, pathPrefix, publicFolder }) =>\n  headers =>\n    _.mapValues(headers, headerList =>\n      _.map(headerList, transformLink(manifest, publicFolder, pathPrefix))\n    )\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/deprecated-packages/gatsby-plugin-gatsby-cloud/src/build-headers-program.js#L49-L85","documentation":"Thrown by `transformLink` in gatsby-plugin-gatsby-cloud's build-headers-program (build-headers-program.js:55). During Gatsby's build, the plugin rewrites `Link:` HTTP header entries so they point at the webpack-hashed asset filename from the build manifest. If the referenced file is neither in the manifest nor on disk in the public folder, the transform aborts the build.","triggerScenarios":"A `Link` header in `gatsby-config.js` (via `gatsby-plugin-gatsby-cloud` options or headers config) referencing an asset that was not emitted by webpack; referencing a file with a typo; referencing an asset whose name changed between versions; headers configured before the asset is generated.","commonSituations":"Adding a `</css/style.css>; as=style; rel=preload` header when the file is actually at `/styles.css`; renaming a font/CSS file but not updating headers; setting headers for assets only produced in certain build modes (e.g. production-only chunks) during a develop build; stale pathPrefix configuration.","solutions":["Open the public/ folder after a build and verify each file referenced in your `Link` headers exists.","Correct the filename/path in the `link` headers config in gatsby-config.js.","If the asset is webpack-emitted, let the plugin resolve the hash from the manifest — reference the un-hashed logical name exactly as it appears in the build output.","Ensure pathPrefix matches between header config and the build."],"exampleFix":"// before — file does not exist in public/\n{\n  resolve: `gatsby-plugin-gatsby-cloud`,\n  options: { headers: { '/*': [`</css/main.css>; as=style; rel=preload`] } }\n}\n\n// after — match the actual emitted filename\n{\n  resolve: `gatsby-plugin-gatsby-cloud`,\n  options: { headers: { '/*': [`</styles.css>; as=style; rel=preload`] } }\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs')\nconst path = require('path')\n\nfunction headersReferenceExisting(publicDir, headers) {\n  const files = new Set(fs.readdirSync(publicDir))\n  return Object.entries(headers).flatMap(([route, list]) =>\n    list.filter(h => /<([^>]+)>/.test(h))\n        .map(h => { const m = h.match(/<([^>]+)>/); return m && !files.has(m[1].replace(/^\\//,'')) ? h : null })\n        .filter(Boolean)\n  )\n}","typeGuard":"function isReferencedFilePresent(publicDir, headerLine) {\n  const m = headerLine.match(/<([^>]+)>/)\n  if (!m) return true\n  const file = m[1].replace(/^\\//, '')\n  return fs.existsSync(path.join(publicDir, file))\n}","tryCatchPattern":null,"preventionTips":["Run `gatsby build` once and inspect public/ before finalizing Link headers.","Reference logical (un-hashed) asset names exactly as webpack emits them.","Add a CI check that validates header-referenced files exist in public/."],"tags":["build","headers","cdn","manifest","gatsby-cloud"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}