fix(sri): resolve hashes using cdnURL at runtime instead of build-time#615
fix(sri): resolve hashes using cdnURL at runtime instead of build-time#615maxmaxme wants to merge 3 commits intoBaroshem:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Could you take a look at it? I think you have more experience in the SRI part :) |
|
Sorry for the delay
@maxmaxme let me know what you think on these 2 |
|
@vejja, hi!
|
|
Thanks @maxmaxme Edit: Also there was a check for the Would be good to have a series of tests that cover having a combination of cdnURL/baseURL values, either not defined or with/without slashes |
Types of changes
Description
This PR fixes a bug in Subresource Integrity (SRI) generation when using dynamic CDN URLs.
Currently,
nuxt-securityuses thecdnURLvalue at build time to construct the keys for the#sri-hashesmap. If the same build is deployed to different environments with different CDN base URLs, the computedsrc/hrefat runtime does not match any entry in the#sri-hashes, andintegrityis not applied.This change defers the use of
cdnURLto runtime, stripping it from the resource URL before matching it against the#sri-hashesmap. This makes SRI compatible with multi-environment deployments using different CDN base URLs set via runtime config (NUXT_APP_CDN_URL).Before:
#sri-hasheskeys were generated usingcdnURLat build timecdnURLchangedAfter:
#sri-hasheskeys are built withoutcdnURLcdnURLbefore lookupThis allows a single build to work reliably across multiple environments with different CDN domains.
Checklist: