reorder home page vapid check to avoid an error on localhost

This commit is contained in:
2024-04-07 09:16:42 -06:00
parent 0fbd1ad51a
commit 2ae165d56f

View File

@@ -340,11 +340,15 @@ export default class App extends Vue {
pushUrl = settings.webPushServer;
}
if (pushUrl.startsWith("http://localhost")) {
console.log("Not checking for VAPID in this local environment.");
} else {
await axios
.get(pushUrl + "/web-push/vapid")
.then((response: VapidResponse) => {
this.b64 = response.data?.vapidKey || "";
console.log("Got vapid key:", this.b64);
console.log("response...", response);
navigator.serviceWorker.addEventListener("controllerchange", () => {
console.log("New service worker is now controlling the page");
});
@@ -360,6 +364,7 @@ export default class App extends Vue {
-1,
);
}
}
} catch (error) {
if (window.location.host.startsWith("localhost")) {
console.log("Ignoring the error getting VAPID for local development.");