DEV: Use isSecureContext for service worker registrations (#19407)
Currently, we check if the site is loaded over `https` before registering the service worker. This prevents the service worker from being registered in a standard dev/test setup. This change replaces the protocol check with `isSecureContext` property check. In addition to resources delivered over `https`, `isSecureContext` returns `true` for resources loaded over `http://127.0.0.1`, `http://localhost`, `http://*.localhost` and `file://`.
This commit is contained in:
parent
1a0473e890
commit
656d0fa762
|
@ -5,9 +5,7 @@ export function registerServiceWorker(
|
|||
serviceWorkerURL,
|
||||
registerOptions = {}
|
||||
) {
|
||||
const isSecured = document.location.protocol === "https:";
|
||||
|
||||
if (isSecured && "serviceWorker" in navigator) {
|
||||
if (window.isSecureContext && "serviceWorker" in navigator) {
|
||||
const caps = container.lookup("capabilities:main");
|
||||
const isAppleBrowser =
|
||||
caps.isSafari ||
|
||||
|
|
Loading…
Reference in New Issue