I made a simple AngularJS to-do app and used sw-toolbox. It is working fine on my localhost but when I am using it on gh-pages, few 404 errors are thrown on console and service worker is also showing 404 error while fetching scripts.
sw-toolbox not working on gh-pages
179 Views Asked by Vivek Sharma At
2
There are 2 best solutions below
0
Devdatta Godbole
On
Since gh pages are hosted using jekyll, jekyll version 3.3 by default ignores node_modules and vendor files. Hence, you won't be getting them when fetched from gh-pages. It will instead log "Failed to load resource" for sw-toolbox.js.
Your can bypass this by adding a simple .nojekyll file to the root of your github repository and your code will work just fine.
Related Questions in ANGULARJS
- Angular Show All When No Filter Is Supplied
- Using pagination on a table in AngularJS
- State with different subviews
- Getting and passing MVC Model data to AngularJS controller
- Implementing prerender.io middleware in sails.js
- Token based authorization in nodejs/ExpressJs and Angular(Single Page Application)
- AngularJS, Google App Engine and URLrewrite
- send data from table to another page into forms
- How to write tests for classes with inheritance
- angularJS sending OPTIONS instead of POST
- Receiving POST from external application in AngularJS
- Metaprogramming AngularJS Filters
- Reload List after Closing Modal
- Why is my angularjs site not completely crawlable?
- Why is separation of JavaScript and HTML a good practice?
Related Questions in GITHUB-PAGES
- Opening PDF in a browser with Github Pages
- Check if cookie exists using Jekyll Liquid
- github page blog from jekyll needs force reload to show changes with posts
- Jekyll - How can I make avoid a paragraph to be added on a YAML frontmatter markdownify item
- Three-level nested list in kramdown
- GitHub Pages Custom Domain Settings
- Using Jekyll for Website without Blog
- Redirect Github pages Jekyll site into sub-directory
- Jekyll Deployment on Github Pages doesn't format correctly (No styling)
- Is it possible to set up a custom domain with GitHub Pages, but keep the original github.io link working without redirection?
- can Jekyll process a markdown file and save it somewhere besides <directory>
- add domain for the github pages, but not effect the project page
- Viewing a separate branch of GitHub Page
- Include HTML5 file in another HTML5 file
- Handle url redirects in angular-cli application deployed to github pages
Related Questions in SERVICE-WORKER
- Encrypting with Crypto Node.js and decrypt with window.crypto in Service-Worker
- Service worker does not load mp3 files
- How to register service workers to a redirected script URL
- HTML5 Push Notifications - examples of other ways to push
- ServiceWorker and Push Notification Payload
- Send Push Notification to everyone with Service Worker
- Polymer auto-register method on platinum-sw-register element
- How can I configure Polymer's platinum-sw-* to NOT cache one URL path?
- Programmatically update service worker if update() is not available
- Service Workers from an iframe for Chrome GCM notifications for web
- Cannot install service worker in Chrome
- Service Worker throws uncaught errors when the server is down
- How to handle fetch events from the very beginning using a Service Worker?
- Server worker being registered twice
- Right place for response parsing in PWA?
Related Questions in SW-TOOLBOX
- Does sw-precache activation of new service worker guarantees cache busting?
- How call a JFrame from my Application Window SWT Builder
- How to show custom 404 page using sw-toolbox sw-precache libraries for service-worker
- Service Worker skipWaiting unable to activate currently waiting SW
- Migrate from Google's sw-toolbox to Workbox SW (Visual Studio)
- sw precache - runtime caching for assets loading from different domain
- PWA [sw-toolbox]: How to cache offline page with all resources?
- ASP.Net /IIS CORS Access-Control-Allow-Origin:* not working for all requests
- Caching XHR get calls using Service Worker Toolbox
- cache api data using sw-toolbox
- sw-toolbox: POST request not getting cached
- Progressive Web App not working in offline mode
- Refresh page after load on cache-first Service Worker
- How to cache googleapis.com using sw-precache runtimeCaching
- How to resolve Dynamic URLs dependencies through Service worker?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The thrown error, TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script., tells us that the SW script itself was never found. The browser tried to fetch the script but was not able to since 404 was returned.
Very simple mistake. Your app tries to register the sw.js file from https://viveksharma619.github.io/sw.js while it's actually located in https://viveksharma619.github.io/PWA_simple_to_do/sw.js
The evil here is /sw.js - on your computer you were probably running the site in localhost:8080 when /sw.js was the real location but now the app lives inside PWA_simple_to_do folder and the sw.js script should be pointed to by either "sw.js" (current folder) or /PWA_simple_to_do/sw.js