Description
I have a .NET 5 Blazor application developed from the standard template using
- WASM App
- Hosted in ASP.NET Core
- PWA
- Individual User Accounts
I am running with Ctrl-F5 and Visual Studio configured to Refresh Browser After Build. When I look at the console in Chrome, I get the following error message:
Refused to load the script 'https://localhost:36001/_framework/aspnetcore-browser-refresh.js' because it violates the following Content Security Policy directive: "script-src 'sha256-fa5rxHhZ799izGRP38+h4ud5QXNT0SFaFlh4eqDumBI='". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
When I look at the source using the inspector I observe that an iFrame has been inserted:
<iframe src="https://localhost:36001/connect/checksession" style="visibility: hidden; position: absolute; display: none; width: 0px; height: 0px;"></iframe>
This iFrame includes <script src="/_framework/aspnetcore-browser-refresh.js"></script>
What is causing this behaviour? In other projects I just see that script being inserted, not the iFrame and the reload works fine. The reload in this case is not working due to the CSP but even that is confusing because the script does not have an integrity attribute.
This seems to be a defect in the logic for how the Refresh functionality is injected. Any help would be much appreciated.
Thanks.