Repository navigation
fix(sri): re-hash public assets after modules have populated them - #759
Open
BobTheShoplifter wants to merge 1 commit into
Open
BobTheShoplifter wants to merge 1 commit into
BobTheShoplifter wants to merge 1 commit into
Conversation
|
@BobTheShoplifter is attempting to deploy a commit to the Baroshem's projects Team on Vercel. A member of the Team first needs to authorize it. |
Public asset directories are still being filled when `nitro:build:before` fires. @nuxt/fonts writes zero-byte placeholder files while Vite resolves the CSS and only downloads the real font data on `rollup:before`, so the existing pass hashes empty files and records the SHA-384 of an empty string for every font. That is harmless until something emits a link for those assets. Setting `preload: true` in the fonts config does exactly that, and because fonts are a destination Chromium enforces SRI on, every font is rejected and the whole site falls back to system fonts. Hashing again on `rollup:before` and merging picks up the real bytes while keeping everything the first pass already resolved.
BobTheShoplifter
force-pushed
the
fix/sri-hash-public-assets-after-population
branch
from
August 30, 2026 15:59
1bb3220 to
8ddf2ec
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SRI hashes are computed on
nitro:build:before, but public asset directories are still being filled at that point.@nuxt/fontswrites zero-byte placeholder files while Vite resolves the CSS, and only downloads the real font data duringrollup:before:So every
/_fonts/*entry in the generated table ends up as the SHA-384 of an empty string:That is harmless until something emits a
<link>for those assets. Settingpreload: truein the fonts config does exactly that, and fonts are a destination Chromium does enforce SRI on, so every font is rejected:Every real
FontFaceends up inerrorstate and the site renders entirely in fallback fonts.Fix
Hash again on
rollup:before, after modules have finished writing, and merge. The second pass corrects the placeholder entries; merging keeps everything the first pass already resolved, which some builds depend on.Verified
On a real Nuxt 4 site with
@nuxt/fontsandpreload: true:integrityvalues across 3 preload linkserrorstateyarn lintclean and all 18 test files pass.Related
#655 covers the same surface but a different cause: whether SRI belongs on
preload/modulepreloadlinks at all. This one is about the hash value itself being wrong. Fixing either would hide this symptom for fonts, but the empty hashes would remain in the table.