I have made a React build, npm start build. When I have uploaded my build to my GitHub page: My React App Github Page .Then I get this error: "Error during service worker registration: DOMException: Only secure origins are allowed". I have tried to make some changes to the index.html file, to try register the service worker like this:
<script type="text/javascript" src="/static/js/main.99691887.js">
if('serviceWorker' in navigator){
// Register service worker
navigator.serviceWorkerContainer.register('service-worker.js').then(function(reg){
console.log("SW registration succeeded. Scope is "+reg.scope);
}).catch(function(err){
console.error("SW registration failed with error "+err);
});
}
</script>
But I still get the error. Is there a way to make this work on my GitHub page?