Copy pasting the issue from #3492
run yarn build,then i open build/index.html,bug get this error,can everyone help me?
Error during service worker registration: DOMException: Failed to register a ServiceWorker: The URL protocol of the current origin ('null') is not supported.
I'm having the same issue. updated create-react-app, but still having the issue
You shouldn't try to "open" index.html, you need to serve it.
When you build, you get instructions in the terminal telling you how to do it. Have you tried following them?
@ankithkonda You can do it by commenting out the following line in index.js
import registerServiceWorker from './registerServiceWorker';
registerServiceWorker();
Then, inside build/index.html, you will need to change the path of every import to relative one using ./ .
For example, change src="/static/js/main.xxx.js" to src="./static/js/main.xsss.js"
You will need to do this for the JS, CSS, manifest and also favicon.
Hope that helps.
Service worker works only on HTTPS connection or localhost. Not file://
Most helpful comment
Service worker works only on HTTPS connection or localhost. Not file://