Hi there, this looks a great module, but we are seeing the following error in our JS console logs and nothing happening after enabling the configuring the module:
Service Worker error: TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script.
Digging into this, on line 67 of main.js - it is calling navigator.serviceWorker.register('/sw.js') which doesn't seem to exist unless /sw.js should be registered somehow?
We've tried changing this to the web accessible path (e.g. /modules/contrib/social_pwa/js/sw.j) which now gets rid of that console error and the pop up works - but still no functionality or questions within the browser. Canceling the modal is fine - accepting it will not dismiss the dialog.
Any ideas?
Many thanks,
James
Comments
Comment #2
heyyo CreditAttribution: heyyo commentedI have the exact same issue.
Comment #3
heyyo CreditAttribution: heyyo commentedMy issue was caused by Nginx. Because the file sw.js is generated by Drupal code, a special NGINX configuration should be added for it, if not NGNIX won't find it.
Comment #4
bramtenhove CreditAttribution: bramtenhove for Open Social commentedThanks heyyo, that is great! I'm curious to know if that also solves your problem jamesfk.
We do define the service worker file in the routing file, but maybe because of the .js extension some webservers don't play nice out of the box.
Comment #5
heyyo CreditAttribution: heyyo commentedUsually all static files including JS, are processed directly by NGINX and not by Drupal. So NGINX checks if the file exists at the current path.
That's why NGINX was returning 404
Comment #6
bramtenhove CreditAttribution: bramtenhove for Open Social commentedThat makes a lot of sense, thanks!
Comment #7
jamesfk CreditAttribution: jamesfk at Website Express Ltd. commentedHi Everyone,
We passed this onto our web hosts, omega8cc and they made this change for us, and I'm very pleased to say it has worked, and suddenly the notifications are working on BOA (using nginx).
Thanks for the tip, heyyo.
All the best,
James
Comment #8
fcgreg CreditAttribution: fcgreg as a volunteer commentedSince it seems like this was a problem specific to NGINX, should we close this issue now?
I'm fairly new around here, so want to defer to @bramtenhove or one of the primary devs. If warranted, we could just include a note about NGINX configuration on the main project page under the "Requirements" section of the "Installation and configuration" section.
Comment #9
fcgreg CreditAttribution: fcgreg as a volunteer commentedMarking as fixed -- problem appears to have been caused by hosting provider configuration.