Error loading appsettings.Production.json due to digest integrity issue Error loading appsettings.Production.json due to digest integrity issue kubernetes kubernetes

Error loading appsettings.Production.json due to digest integrity issue


I edited the wwwroot/service-worker.published.js file, which first lines are as follow:

// Caution! Be sure you understand the caveats before publishing an application with// offline support. See https://aka.ms/blazor-offline-considerationsself.importScripts('./service-worker-assets.js');self.addEventListener('install', event => event.waitUntil(onInstall(event)));self.addEventListener('activate', event => event.waitUntil(onActivate(event)));self.addEventListener('fetch', event => event.respondWith(onFetch(event)));const cacheNamePrefix = 'offline-cache-';const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`;const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ];const offlineAssetsExclude = [ /^service-worker\.js$/ ];async function onInstall(event) {    console.info('Service worker: Install');    // Fetch and cache all matching items from the assets manifest    const assetsRequests = self.assetsManifest.assets        .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url)))        .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url)))        .map(asset => new Request(asset.url, { integrity: asset.hash }));    await caches.open(cacheName).then(cache => cache.addAll(assetsRequests));}...

I added an array of patterns, similar to offlineAssetsInclude and offlineAssetsExclude to indicate which files I want to skip integrity checks.

...const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ];const offlineAssetsExclude = [ /^service-worker\.js$/ ];const integrityExclude = [ /^appsettings\.Production\.json$/ ]; // <-- new variable

Then at onInstall, instead of always returning a Request with integrity set, I skipped it for excluded patterns:

...async function onInstall(event) {    console.info('Service worker: Install');    // Fetch and cache all matching items from the assets manifest    const assetsRequests = self.assetsManifest.assets        .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url)))        .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url)))        .map(asset => {            // Start of new code            const integrity =                integrityExclude.some(pattern => pattern.test(asset.url))                ? null                : asset.hash;            return !!integrity               ? new Request(asset.url, { integrity })               : new Request(asset.url);            // End of new code        });    await caches.open(cacheName).then(cache => cache.addAll(assetsRequests));}...

I'll wait for others to comment and propose other solutions, because the ideal response would set the correct SHA hash to the file, instead of ignoring it.