-
Notifications
You must be signed in to change notification settings - Fork 75
fix(sri): resolve hashes using cdnURL at runtime instead of build-time #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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: