.netblazorblazor-webassemblycontent-security-policy

Refused to create a worker from 'blob:https://x/6a...293' because it violates the following Content Security Policy directive


I have Blazor web assembly application (client + server) and keep Refused to create a worker because it violates the following CSP directive.

It works locally but when I'm trying to publish my app and test published release (with self-signed ssl) I keep getting this annoying problem and I do not understand how to disable or modify CSP policy, so I can test publish version properly.

This is my current meta :

<meta http-equiv="Content-Security-Policy" content="img-src * data: blob:; worker-src 'self' 'unsafe-inline' * blob:;">

This code on server to ensure I will never will get any another SCP policies from server.

    app.Use(async (context, next) =>
    {
        context.Response.Headers.Remove("Content-Security-Policy");
        await next.Invoke();
    });

But I still keep getting this error : enter image description here

And I don't even know If this error will go away if I will configure proper SSL connection since I installed my current self-signed certificate as trusted, and run chrome these parameters :

 --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://xxxx/

So I don't understand why I still have these errors.


Solution

  • Check your response headers in production for any CSPs present there. When you add another policy in meta, that can only make your policy stricter. You need to identify how the policy in production is set and modify it. Also, the blob: source needs to be added to script-src or worker-src.