Problem with Content Security Policy on App Service

Samo Simončič 1 Reputation point
2021-09-07T13:09:30.53+00:00

We are hosting WordPress on the App Service. We would like to have google analytics but it seems that the default Content Security Policy on App Service blocks the google analytics request. We get the following error:

Refused to load the script 'https://www.googletagmanager.com/gtag/js?id=UA-14354' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'unsafe-inline' *.msecnd.net *.google.com *.gstatic.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Can someone tell me where I can change Content Security Policy on App Service? I was trying to add the following code

<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="default-src 'self';"/>
</customHeaders>
</httpProtocol>

in web.confing file via Kudo but every time I get the following error:

The page cannot be displayed because an internal server error has occurred.

I will appreciate for help.

Samo

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.