てぃぐれのプログラマwiki

ワクワクに従う

Failed to find a valid digest in the 'integrity' attribute for resource 【C# Blazor】

経緯

Failed to find a valid digest in the 'integrity' attribute for resource 'domain/_framework/〇〇.dll' with computed SHA-256 integrity 'XXXXXXXXXXXXXXXX. The resource has been blocked.

 

上記のようなエラーがデプロイ環境で起きた。

ローカル環境は動くのに。

 

対応

下記サイトにあるように対応してうまくいった。

.net core - Failed to find a valid digest in the 'integrity' attribute for resource in Blazor app - Stack Overflow

If was the issue, please try this:

  1. Close VS.
  2. Delete the obj and bin folders from all your projects. (the web project might be enough, but hey - can't hurt)
  3. Start VS
  4. Rebuild solution.
  5. Try Publish again.

 

削除したファイルはビルド時に再度生成される。

もっと細かく対応すると、blazor.boot.jsonのファイルを消す。

その中のファイルで先ほどのエラーの中のハッシュ化されたキー見つかる。

このファイルを消してあげてビルドするとうまく再生成され、デプロイがうまくいった。