Jump to content

JavaScript Problem


Recommended Posts

After using Content-Security-Policy(CSP) the javascriptsfrom other sources are not working properly. What can I do?

 

Part of my .htaccess is:

 

Header set Strict-Transport-Security "max-age=631138519; includeSubDomains"
Header unset Content-Security-Policy
Header set Content-Security-Policy "script-src 'self' 'https://apis.google.com' 'https://www.googletagmanager.com/' 'https://ajax.googleapis.com' 'https://maxcdn.bootstrapcdn.com' 'https://cse.google.com/'"
Header unset X-Content-Security-Policy
Header set X-Content-Security-Policy "default-src 'self' 'https://apis.google.com' 'https://www.googletagmanager.com/' 'https://ajax.googleapis.com 'https://maxcdn.bootstrapcdn.com' 'https://cse.google.com/'"
Header unset X-WebKit-CSP
Header set X-WebKit-CSP "default-src 'self' 'https://apis.google.com' 'https://www.googletagmanager.com/' 'https://ajax.googleapis.com' 'https://maxcdn.bootstrapcdn.com' 'https://cse.google.com/'"
Header unset Referrer-Policy
Header set Referrer-Policy: strict-origin-when-cross-origin

 

 

Edit: The CSS are working

Edited by rajdis
Link to comment
Share on other sites

We haven't been paying much attention up here the past few days due to the hack...sorry about that. Try removing the single quotes around the URLs. Also, try removing all of the URLs except one, and see if the matching script loads (with all others being expected to fail). If so, add a second URL, and repeat.

 

Also, your site does use inline scripting which is blocked when using CSP, so your site is going to break to an extent even when it works correctly.

  • Like 1
Link to comment
Share on other sites

I am getting this following error:

 

17:00:54.506 Content Security Policy: The page’s settings blocked the loading of a resource at self (“script-src https://distribure.cf https://apis.google.com https://www.googletagmanager.com https://ajax.googleapis.com https://maxcdn.bootstrapcdn.com https://cse.google.com”). Source:
  window.dataLayer = window.dataLayer |.... 1 web_design.php:117
 

The updated .htaccess is:

 

Header set Content-Security-Policy "script-src 'self' https://apis.google.com https://www.googletagmanager.com https://ajax.googleapis.com https://maxcdn.bootstrapcdn.com https://cse.google.com ;"

Link to comment
Share on other sites

I did some digging last night and you're not the first to have this issue here...someone else ran into this a while back too. No fix was ever found.

 

Reports on Google show success sending these using PHP's header() function, perhaps that's an option? Make a file with the code and require() in all relevant pages.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...