FIX: Service Worker URL was broken

Behavior was changed in #9966, which made the URL be relative.

If the user landed in a topic, for example, the browser was given a
service worker URL under that specific topic URL, which was a 404.

Fixes broken PWA install and broken push notifications
This commit is contained in:
Rafael dos Santos Silva 2020-06-04 14:49:39 -03:00
parent a23d31e4d6
commit f00e5515e4
No known key found for this signature in database
GPG Key ID: 5E50360227B34938
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { isAbsoluteURL } from "discourse-common/lib/get-url";
import getURL from "discourse-common/lib/get-url";
import getAbsoluteURL from "discourse-common/lib/get-url";
export default {
name: "register-service-worker",
@ -33,7 +33,7 @@ export default {
});
navigator.serviceWorker
.register(`${getURL(Discourse.ServiceWorkerURL)}`)
.register(getAbsoluteURL(`/${Discourse.ServiceWorkerURL}`))
.catch(error => {
// eslint-disable-next-line no-console
console.info(`Failed to register Service Worker: ${error}`);