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 <luzar.david@gmail.com>
This commit is contained in:
Aakansha Doshi 2021-10-26 18:19:41 +05:30 committed by GitHub
parent d7cdee37bf
commit 516e7656f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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);

View File

@ -22,5 +22,11 @@
}
]
}
],
"rewrites": [
{
"source": "/webex/:match*",
"destination": "https://excalidraw-webex-lp.vercel.app/:match*"
}
]
}