Workbox: CORS Issue with Google Analytics

Created on 16 Aug 2017  Â·  8Comments  Â·  Source: GoogleChrome/workbox

Welcome! Please use this template for reporting bugs or requesting features. For questions about using Workbox, the best place to ask is Stack Overflow, tagged with [workbox]: https://stackoverflow.com/questions/ask?tags=workbox

Library Affected:
workbox-google-analytics.prod.v1.3.0.js

Browser & Platform:
Google Canary V62

Issue or Feature Request Description:
Everything was fine running in Google Canary V61 and when I upgrade to Google Canary V62, I get this error message:

Failed to load https://www.google-analytics.com/collect: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.example.com' is therefore not allowed access. The response had HTTP status code 405. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

When reporting bugs, please include relevant JavaScript Console logs and links to public URLs at which the issue could be reproduced.

Look forward to people's replies.

All 8 comments

Hi,

Sorry this seems to be a silly mistake by me. I had Adblock Plus turned off, but installed in Google Canary. Even though I had it turned off and also not to block anything on the website it was still working some how.

I had an extension called: "EasyPrivacy" installed in Adblock Plus and that was cauing the CORS problem with workbox-google-analytics 2.0.0

I turned that module off and no problems...?

p.s. Gonna closed this issue and leave this comment.

Thanks @ayumihamsaki, FWIW I recently rewrote much of the workbox-google-analytics replay logic to try to avoid issues like this.

Once #770 gets merged, I'd be curious to know if these types of issues get better.

@philipwalton Wow you have really changed a lot of the code there. Is that a forthcoming version? Or is it version 2.0.0 thanks.

Yeah, the change was to have it use background sync, but that means almost everything changed.

I think the plan at the moment is to hold off until v3.

@philipwalton Is it possible to make V3 an OriginTrials (https://github.com/GoogleChrome/OriginTrials) and then we can beta test it and help you.

I don't think we'd make a library API an origin trial (I think it's reserved for browser APIs), but @addyosmani can probably say more definitively.

Guys, This is my site.
http://hottravelfares.com/WinYourTrip.html
I get the following error.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.google-analytics.com/collect. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Can u tell me how to fix?
@ayumihamsaki

@chanakaDe what version of Workbox are you using?

Was this page helpful?
0 / 5 - 0 ratings