Here is my app’s current way to handle the maintenance process:
I have an environment variable for the app status:
REACT_APP_SITE_MODE=“LIVE” | “MAINTENANCE”
I'm using react-router
for routing the app:
switch (process.env.REACT_APP_SITE_MODE) {
case "MAINTENANCE":
return (
<Switch>
<Route component={MaintenancePage} />
</Switch>
);
default:
return (
<Switch>
{/* Default routes */}
</Switch>
);
}
This works fine but when we just switch it to the maintenance mode, some users can still access the app with the default routes (this is not good when the backend is down), I think it’s because of the browser cache or something.
My question is:
- How to prevent users from accessing the app during the maintenance period? (force them to clear their cache in that specific time?)
- Is there a better way to handle the maintenance process?
Thanks.