Failed to register a ServiceWorker when PUBLIC_URL is CDN
Created by: micooz
Can you reproduce the problem with latest npm?
Yes.
Description
When set PUBLIC_URL
to a cdn address, service worker registration is blocked. It seems a cross-domain problem:
Error during service worker registration: DOMException: Failed to register a ServiceWorker: The origin of the provided scriptURL ('https://o0tu0aq0f.qnssl.com') does not match the current origin ('https://apporz.com').
Expected behavior
ServiceWorker should work well when PUBLIC_URL
isn't local host.
Actual behavior
ServiceWorker doesn't work.
Environment
-
npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.6 -
node -v
: v7.10.0 -
npm -v
: v4.2.0
Then, specify:
- Operating system: macOS
- Browser and version: Chrome 58.0.3029.110 (64-bit)
Reproducible Demo
See console output on my website.