Create-react-app: Failed to register a ServiceWorker: The URL protocol of the current origin ('null') is not supported

Created on 9 Feb 2018  路  3Comments  路  Source: facebook/create-react-app

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

question

Most helpful comment

Service worker works only on HTTPS connection or localhost. Not file://

All 3 comments

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://

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdamian3 picture rdamian3  路  3Comments

fson picture fson  路  3Comments

DaveLindberg picture DaveLindberg  路  3Comments

Aranir picture Aranir  路  3Comments

ap13p picture ap13p  路  3Comments