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:
parent
d7cdee37bf
commit
516e7656f3
@ -37,6 +37,13 @@ export const register = (config?: Config) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("load", () => {
|
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`;
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
if (isLocalhost) {
|
if (isLocalhost) {
|
||||||
@ -135,11 +142,14 @@ const checkValidServiceWorker = (swUrl: string, config?: Config) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const unregister = () => {
|
export const unregister = (callback?: () => void) => {
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.ready
|
navigator.serviceWorker.ready
|
||||||
.then((registration) => {
|
.then((registration) => {
|
||||||
registration.unregister();
|
return registration.unregister();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
callback?.();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
|
@ -22,5 +22,11 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"rewrites": [
|
||||||
|
{
|
||||||
|
"source": "/webex/:match*",
|
||||||
|
"destination": "https://excalidraw-webex-lp.vercel.app/:match*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user