Closed justindra closed 7 years ago
Hello, I can't give you right now a fix because it's too late here but I think I got the problem : as each subdomain is considered as a new origin we need to have to deal with Cross-Origin Resources https://www.w3.org/TR/service-workers/#cross-origin-resources
Cool! Thanks for that info. I will have a go and see if I can fix it as well.
First, as I can't access anything but my phone I can't test anything. But I made some search and here's what I come up with. There is three reponse.type : basic, cors and opaque. If you fetch from same origin the response.type is basic. Otherwise it's either cors or opaque. You probably do not want opaque as we can't read data from it. So cors seems to fits for you case and accordingly to google to have cors type you just need to return a cors header. So could you check if you subdomain return propers CORS headers and if all is in https (mandatory for service worker)
So it is returning proper CORS headers. Although, the subdomain where the images are, are not on a https subdomain. I will see if I can update that.
I'm actually surprised of that, I tought load assets from a subdomain which is not https to a domain which is have HTTPS wasn't possible (I mean I experience that problem where I secure my main domain but not my subdomain). And I assume your main domain have HTTPS otherwise SW doesn't run.
Yep, so my main domain has HTTPS, and my subdomain was a cname to an S3 bucket which turns out does not forward through the ssl cert. So I've changed it back to use the S3 bucket url provided, which is https and that seems to fix the problem.
So I guess this isn't actually a problem with CORS. I will close for now.
So the first time I load the page, it works perfectly, but then if I hit refresh, some images do not load (these are loaded from a different subdomain).