Skip to content

Commit

Permalink
Merge pull request #396 from Baroshem/fix-sri-broken-nuxt-3.9
Browse files Browse the repository at this point in the history
sri: fetch buffers from storage and convert to object
  • Loading branch information
Baroshem authored Mar 9, 2024
2 parents 13a96a6 + b3a5125 commit 6e01494
Show file tree
Hide file tree
Showing 3 changed files with 1,935 additions and 2,163 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"packageManager": "[email protected]",
"dependencies": {
"@nuxt/kit": "^3.8.0",
"@nuxt/kit": "^3.10.3",
"basic-auth": "^2.0.1",
"cheerio": "^1.0.0-rc.12",
"defu": "^6.1.1",
Expand All @@ -62,14 +62,14 @@
},
"devDependencies": {
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/module-builder": "^0.5.2",
"@nuxt/schema": "^3.8.0",
"@nuxt/test-utils": "^3.8.0",
"@nuxt/module-builder": "^0.5.5",
"@nuxt/schema": "^3.10.3",
"@nuxt/test-utils": "^3.11.0",
"@types/node": "^18.18.1",
"eslint": "^8.50.0",
"nuxt": "^3.8.0",
"nuxt": "^3.10.3",
"typescript": "^5.2.2",
"vitest": "^1.0.4"
"vitest": "^1.3.1"
},
"stackblitz": {
"installDependencies": false,
Expand Down
7 changes: 4 additions & 3 deletions src/runtime/nitro/plugins/03-subresourceIntegrity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ export default defineNitroPlugin((nitroApp) => {
//
// - Conversely, if we are in a standalone SSR server pre-built by nuxi build
// Then we don't have a .nuxt build directory anymore
// But we did save the /integrity directory into the server assets
// But we did save the /integrity directory into the server assets
const prerendering = isPrerendering(event)
const storageBase = prerendering ? 'build' : 'assets'
const sriHashes: Record<string, string> = await useStorage(storageBase).getItem('integrity:sriHashes.json') || {}
const storageBase = prerendering ? 'build' : 'assets'
const sriHashesRaw = await useStorage(storageBase).getItemRaw<Uint8Array>('integrity:sriHashes.json')
const sriHashes: Record<string, string> = sriHashesRaw ? JSON.parse(new TextDecoder().decode(sriHashesRaw)) : {}

// Scan all relevant sections of the NuxtRenderHtmlContext
// Note: integrity can only be set on scripts and on links with rel preload, modulepreload and stylesheet
Expand Down
Loading

0 comments on commit 6e01494

Please sign in to comment.