gatsby
gatsby copied to clipboard
gatsby-plugin-gatsby-cloud: LINK_REGEX constant is missing; Link header replacements don't work
Preliminary Checks
- [X] This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- [X] This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
With the gatsby-plugin-gatsby-cloud plugin, it seems that the Link header replacements do not work.
(Gatsby Cloud issue 28006)
The build headers file https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-gatsby-cloud/src/build-headers-program.js#L8 references a constant, but this constant does not seem to exist in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-gatsby-cloud/src/constants.js or in the repository overall.
The constant is later used in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-gatsby-cloud/src/build-headers-program.js#L60 to replace file names in Link headers according to the manifest, but it does not happen on production.
Reproduction Link
(non-public, Cloud issue 28006)
Steps to Reproduce
- Add the
gatsby-plugin-gatsby-cloud
plugin - Make sure there is a font file somewhere in
src/
, it is referenced though your build, it ends up inpublic/static
stamped after the build and there is apublic/assets-manifest.json
file referencing both that font original filename and a "stamped" filename. - configure it like
options: {
allPageHeaders: [
'Link: </static/font.woff2>; rel=preload; as=font',
'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload',
],
- Deploy to Gatsby Cloud and
GET /
Expected Result
The reference to that font file in the Link header has a replacement: /static/font-${stamphere}.woff2
instead of /static/font.woff2
according to the assets manifest file.
Actual Result
The Link header is sent as is (/static/font-${stamphere}.woff2
), resulting in 404 (as the file at that path is stamped after the build)
Environment
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Pro
Shell: 5.9 - /opt/homebrew/bin/zsh
Binaries:
Node: 18.9.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.2 - /opt/homebrew/bin/npm
Browsers:
Chrome: 105.0.5195.125
Firefox: 104.0.2
Safari: 16.0
npmPackages:
gatsby: 4.22.0 => 4.22.0
gatsby-background-image: 1.6.0 => 1.6.0
gatsby-core-utils: 3.22.0 => 3.22.0
gatsby-plugin-canonical-urls: 4.22.0 => 4.22.0
gatsby-plugin-gatsby-cloud: 4.22.0 => 4.22.0
gatsby-plugin-google-tagmanager: 4.22.0 => 4.22.0
gatsby-plugin-image: 2.22.0 => 2.22.0
gatsby-plugin-iubenda-cookie-footer: 1.4.0 => 1.4.0
gatsby-plugin-loadable-components-ssr: 4.2.1 => 4.2.1
gatsby-plugin-mdx: 3.20.0 => 3.20.0
gatsby-plugin-postcss: 5.22.0 => 5.22.0
gatsby-plugin-preact: 6.22.0 => 6.22.0
gatsby-plugin-react-social-cards: 1.0.0 => 1.0.0
gatsby-plugin-remove-generator: 1.2.0 => 1.2.0
gatsby-plugin-robots-txt: 1.7.1 => 1.7.1
gatsby-plugin-sharp: 4.22.0 => 4.22.0
gatsby-plugin-sitemap: 5.22.0 => 5.22.0
gatsby-plugin-svgr: 3.0.0-beta.0 => 3.0.0-beta.0
gatsby-plugin-webpack-bundle-analyser-v2: 1.1.27 => 1.1.27
gatsby-remark-copy-linked-files: 5.22.0 => 5.22.0
gatsby-remark-prismjs: 6.22.0 => 6.22.0
gatsby-remark-smartypants: 5.22.0 => 5.22.0
gatsby-source-filesystem: 4.22.0 => 4.22.0
gatsby-source-iubenda-documents: 2.1.0 => 2.1.0
gatsby-source-mock: ^1.2.1 => 1.2.1
gatsby-transformer-sharp: 4.22.0 => 4.22.0
Config Flags
No response