Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to register a ServiceWorker (Flutter)

I'm working on a Flutter Web App and today I got these errors:

A bad HTTP response code (404) was received when fetching the script.

Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://adrieldf.github.io/') with script ('https://adrieldf.github.io/flutter_service_worker.js'): A bad HTTP response code (404) was received when fetching the script.

The only thing "different" that I added to the code was a dependency for the Share library, but I don't think that that is the problem.

Here is the interesting thing, I've got the app hosted on Github Pages and after every commit I have a action that builds the web app. After the build, when I try to access it doesn't load and the errors appears. But building it and running it locally works normally.

Here is the source code if you want to check: https://github.com/Adrieldf/allthewidgets The website link is in the repo description.

like image 312
Adriel Avatar asked Mar 13 '20 19:03

Adriel


1 Answers

I solved my problem by changing the index.html file

from <base href="/">

to <base href="/directory_name/">

like image 101
Daniel Baltazar Schneider Avatar answered Oct 03 '22 03:10

Daniel Baltazar Schneider