From 516e7656f303cf6a72160f10cbd9e6907e2500bc Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 26 Oct 2021 18:19:41 +0530 Subject: [PATCH] feat: Add rewrite to webex landing page (#4102) * feat: Add rewrite to webex landing page * blacklist webex url * dont cache webex * Unregister sw for webex * fix * fix * reload in callback Co-authored-by: dwelle --- src/serviceWorker.tsx | 14 ++++++++++++-- vercel.json | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/serviceWorker.tsx b/src/serviceWorker.tsx index 1ef7271a..1784c8aa 100644 --- a/src/serviceWorker.tsx +++ b/src/serviceWorker.tsx @@ -37,6 +37,13 @@ export const register = (config?: Config) => { } window.addEventListener("load", () => { + const isWebexLP = window.location.pathname.startsWith("/webex"); + if (isWebexLP) { + unregister(() => { + window.location.reload(); + }); + return false; + } const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; if (isLocalhost) { @@ -135,11 +142,14 @@ const checkValidServiceWorker = (swUrl: string, config?: Config) => { }); }; -export const unregister = () => { +export const unregister = (callback?: () => void) => { if ("serviceWorker" in navigator) { navigator.serviceWorker.ready .then((registration) => { - registration.unregister(); + return registration.unregister(); + }) + .then(() => { + callback?.(); }) .catch((error) => { console.error(error.message); diff --git a/vercel.json b/vercel.json index e9507373..75a3de25 100644 --- a/vercel.json +++ b/vercel.json @@ -22,5 +22,11 @@ } ] } + ], + "rewrites": [ + { + "source": "/webex/:match*", + "destination": "https://excalidraw-webex-lp.vercel.app/:match*" + } ] }