next.jsadsensesharedarraybuffercross-origin-embedder-policycross-origin-opener-policy

Is there a way to use Google Adsense with cross origin isolation?


I am developing a website that uses depends on SharedArrayBuffer, to use SharedArrayBuffer your website needs to be cross origin isolated, which means your server response needs to contain the following headers:

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin

I am using next.js and the headers seem to be working as I can check for cross origin isolation with the crossOriginIsolated global variable.

It seems like it is breaking Google Adsense as it is giving me these errors.

VM9:2747 crbug/1173575, non-JS module files deprecated.
show_ads_impl.js:101 GET https://www.googletagservices.com/activeview/js/current/osd.js net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep
VM48:2747 crbug/1173575, non-JS module files deprecated.
show_ads_impl.js:82 GET https://tpc.googlesyndication.com/sodar/sodar2.js net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep
show_ads_impl.js:82 Uncaught (in promise) undefined

Any ideas?

Thanks in advance.


Solution

  • Google Ads have no plans to support cross-origin isolation. The recommendation is to register for an origin trial to temporarily exempt your domain to continue using SharedArrayBuffer without cross-origin isolation.

    Good news is, the Chrome team is working on a workaround for this issue without this temporary exemption.

    You can learn more about this matter here: https://developers.google.com/publisher-tag/guides/cross-origin-embedder-policy