When I deploy my asp.net Blazor WASM app I get the following error when MSAL tries to authenticate.
window.crypto.randomUUID is not a function
I've seen this article on microsoft's website, not sure if it is related or not, but I wouldn't have expected MS to use it in .NET 7 if it was removed.
I can't work out what to do about this, can anyone help?
What I've tried so far
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
</ItemGroup>
<ItemGroup>
<BlazorLinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
with this in the xml file
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="Microsoft.Authentication.WebAssembly.Msal" />
</linker>
The problem was that window.crypto.randomUUID only runs when your domain is localhost, or when the request is via HTTPS.
Solution: Instead of http (which seems to be VS default after publishing) use https.