Browse Source

reorder home page vapid check to avoid an error on localhost

feat/vitejs-trent
Trent Larson 8 months ago
parent
commit
2ae165d56f
  1. 5
      src/App.vue

5
src/App.vue

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

Loading…
Cancel
Save