qadenza
qadenza

Reputation: 9293

No 'Access-Control-Allow-Origin' error while embeding youtube video

here is my embed code:

<iframe src="https://www.youtube-nocookie.com/embed/x9pRNcoP1EU" frameborder="0" allowfullscreen></iframe>

here is the error in console

Access to XMLHttpRequest at 'https://googleads.g.doubleclick.net/pagead/id' from origin 'https://www.youtube-nocookie.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I tried to add the following at the top of php page - without success

header("Access-Control-Allow-Origin: *");  

how to solve this?

Upvotes: 4

Views: 7968

Answers (2)

Mark Bosky
Mark Bosky

Reputation: 127

As @david-vielhuber said in the comments, this isn't related to your domain but to the CORS policy on "googleads.g.doubleclick.net". There is nothing you can do beyond changing the way you embed YouTube videos.

example of CORS Policy Error: CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

CORS Policy Reference

Upvotes: 6

chuebert
chuebert

Reputation: 136

add this to your .htaccess: Header set Access-Control-Allow-Origin "*"

Upvotes: 0

Related Questions