Failed to register a ServiceWorker (Flutter) Failed to register a ServiceWorker (Flutter) dart dart

Failed to register a ServiceWorker (Flutter)


Looks, like you are trying to run the project from the project_root/web folder.

If you just start a webserver here (for example, by using python -m http.server 8088), the application will start and even will be working partially.

But compiled web app located in project_root/build/web. Try to run your webserver in that folder.


Well, the problem is what the error message says. Your JS is trying to register a Service Worker from the script 'https://adrieldf.github.io/flutter_service_worker.js' but that does not exist on the server. If you open that URL it's a 404.


I solved my problem by changing the index.html file

from<base href="/">

to<base href="/directory_name/">