XMLHttpRequest cannot load https://googleads.g.doubleclick.net/pagead/id. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access.
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://imasdk.googleapis.com').XMLHttpRequest cannot load https://googleads.g.doubleclick.net/pagead/id. Redirect from 'https://googleads.g.doubleclick.net/pagead/id' to 'https://googleads.g.doubleclick.net/pagead/id?dpt=1' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access.
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://imasdk.googleapis.com').XMLHttpRequest cannot load https://googleads.g.doubleclick.net/pagead/id. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access.
Access-Control-Allow-Origin: <origin header value>Access-Control-Allow-Credentials: true
$ curl --head --header "Origin: foobar" --request GET 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=1263514'
HTTP/1.1 200 OKP3P: policyref="https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml", CP="CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"Timing-Allow-Origin: *Google-MediationGroup-Id: -2Access-Control-Allow-Origin: foobarAccess-Control-Allow-Credentials: true...[SOME OTHER STUFF REMOVED IN THE INTERESTS OF BREVITY]
Transfer-Encoding: chunked
Cross-Origin-Resource-Sharing (CORS) for VASTModern browsers apply same-origin security restrictions to JavaScript network requests, meaning that a web application running from one origin cannot retrieve data served from a different origin. For VAST, this security restriction prevents JavaScript XMLHttpRequests made from JavaScript VAST rendering code from reading a VAST ad response served from a different origin.
This security restriction is meant to prevent issues where one origin is able to read data from another origin that a user may be logged into without that user's permission. The restriction poses problems for VAST served in a JavaScript environment because an ad server is often on a different domain than the ads player.Cross-Origin Resource Sharing (CORS) headers is a W3C draft specification meant to allow sharing across different origins. To be servable in a JavaScript environment a VAST ad server's response must include the following HTTP CORS headers:
Access-Control-Allow-Origin: <origin header value>Access-Control-Allow-Credentials: true
This HTTP header allows an ads player on any origin to read the VAST response from the ad server origin. The value of Access-Control-Allow-Origin: should be the value of the Origin header sent with the ad request. The Access-Control-Allow-Credentials: header will ensure that cookies will be sent and received properly.For more information, refer to the W3C Draft Specification on Cross-Origin Resource Sharing
Thanks for taking a look at the Video Suite Inspector page, Chris Feidman. The Video Suite Inspector is one of the yardsticks of the industry, so as a community, we need that page to behave without issue. I also see CORS errors when playing back the ad.
If you've seen CORS errors from serving a properly configured tag on one of our reference implementations then please share the tag and steps to reproduce the issue. I would be happy to look further into the issue.
[Error] Unable to post message to https://www.youtube.com. Recipient has origin https://imasdk.googleapis.com.postMessageC (www-widgetapi.js:119:451)H (www-widgetapi.js:116)(anonymous function)
XMLHttpRequest cannot load https://googleads.g.doubleclick.net/pagead/id. Redirect from 'https://googleads.g.doubleclick.net/pagead/id' to 'https://googleads.g.doubleclick.net/pagead/id?dpt=1' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access.
To your broader issue, if the CORS header on the ad server is configured correctly then the SDK should supply all the proper parameters to avoid an error. There is no overhead needed on your part.
We actually don't support the Video-JS IMA plugin on this forum. You'll have to reach out to that team directly on their GitHub issue tracker. This support channel is only for native SDK implementation queries.
Use case | Typical Error | Possible Solution |
Video Suite Inspector (VSI) reference implementation. | Chrome reports... Redirect from 'https://www.google-analytics.com/r/collect?v=1&_v=j54&a=572720829&t=event&_…2.1494471726&_r=1&cd5=en&cd3=0&cd8=scriptsafe&cd1=Signed%20out&z=184818249' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://google-developers.appspot.com' is therefore not allowed access. | Caused by an error on the underlying webpage that hosts the IMA SDK reference player rather than the IMA SDK itself. Solution: IMA SDK team have reached out to the team who host the Video Suite Inspector page. |
Official VideoJS-IMA plugin | Safari reports… |
[Error] Unable to post message to https://www.youtube.com. Recipient has origin https://imasdk.googleapis.com. |
The official VideoJS-IMA plugin is not supported by this IMA SDK forum. Solution: Publisher should reach out to the VideoJS-IMA team through the Github Issue Tracker. | |
Any IMA reference page where the user has the official Doubleclick Publisher Toolbar (DPT) extension installed. | Chrome reports… |
XMLHttpRequest cannot load https://googleads.g.doubleclick.net/pagead/id. Redirect from 'https://googleads.g.doubleclick.net/pagead/id' to 'https://googleads.g.doubleclick.net/pagead/id?dpt=1' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access. |
The official Google Doubleclick Publisher Toolbar (DPT) hijacks the ad request request, but during the redirect process modifies the origin headers. Look for dpt=1. Solution: Disable the official Google Doubleclick Publisher Toolbar extension. If the Google AdSense team reject your player implementation and point you to https://developers.google.com/interactive-media-ads/docs/sdks/html5/ads#cors, ignore the default response, explain that this advice is not relevant (AdSense IS the ad server), and ask the AdSense team to re-test without the Doubleclick Publisher Toolbar enabled. | ||
Any VAST player pointing to an ad server which does not follow VAST 3.0 best practice for CORS. | Chrome reports… The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://imasdk.googleapis.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. | This is caused by the VAST 2.x/3.x/4.x ad server not following the CORS guidelines in the VAST 3.0 Specifications or Google's Best Practice for IMA. (DFP, AdSense, Ad Exchange are all compliant) Solution: Reach out to your ad partner and raise a bug. Point them in the direction of the VAST 3.0 specification. This is the one and only case where https://developers.google.com/interactive-media-ads/docs/sdks/html5/ads#cors is relevant. |
Official IMA HTML5 Reference Implementation | Safari reports… |
[Error] Unable to post message to https://www.youtube.com. Recipient has origin https://imasdk.googleapis.com. |
Screenshot attached to this post. Probably the same error as VideoJS-IMA plugin. Solution: ??? |
About your final question regarding the error in your screenshot, I'm going to have to again direct you to the videojs-ima GitHub Issue Tracker. The URL at the top of the page shows that you're on the Video-JS reference page.
The screenshot you shared shows that you're using one of our ad rules sample tags and because I couldn't tell which one, I tested them all a few times, clearing my cache before each test.