Search code examples
javascriptlaravelpushpad

Registering Serviceworker in Laravel


I'm using pushpad (from pushpad.xyz) and followed the 3 initial steps to setup this SDK with my Laravel 5.5 Project. But as soon as I visit a test view it just cannot find and register the Serviceworker.js i tried placing it all over the place, almost in every folder now. So i know this is vaguely described but if you take a quick look at the Docs from pushpad you know what I mean. Moreover, when i manually try to open it i get a 404. also getting 404 when i try to import it via from the https:// link where its located when i copy its content and use it in a script tag i also get a 404. im quite clueless as how to proceed

A bad HTTP response code (404) was received when fetching the script.
Failed to load resource: net::ERR_INVALID_RESPONSE
push-test:1 Uncaught (in promise) TypeError: Failed to register a 
ServiceWorker: A bad HTTP response code (404) was received when fetching the 
script.

Solution

  • You need to make sure that you have a service-worker.js file in the root directory of your website.

    You can verify the installation by typing https://example.com/service-worker.js in your browser.