ServiceWorker registration failed: only secure origins are allowed

The browser refused registration because the page was outside a secure context. Check the page’s actual URL. A development test on localhost can work while the same app opened over plain HTTP on a LAN address or public hostname fails.
Serve the page and worker over HTTPS outside local development. Check window.isSecureContext and then check whether navigator exposes the service worker API before registering.
Check the final hostname and scheme users reach after redirects. The local development URL can qualify as a secure context while a plain HTTP deployment on a LAN address does not.
const secure = window.isSecureContext; if (secure && 'serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js'); }
Check window.isSecureContext on the exact page that registers the worker, then test the HTTPS deployment.