Hello,
I'll go straight to the point. I have an Angular application that uses Firebase for hosting, database, authentication, cloud functions and trying to figure out how I can implement a 'maintenance mode'.
What does the 'maintenance mode' I'm trying to achieve look like? Basically I want to be able to trigger this mode, when maintenance is performed (actions that could affect the user experience or that need no user to be interacting with resources), achieving this two things:
- All active sessions (or authenticated users if that's a more accurate term since i'm using firebase auth) to be redirected from whichever page they are to a 'maintenance.html' static file. They should also not be able to access a different page than this if typing a route they know directly in the browser.
- Future sessions are automatically redirected to the 'maintenance.html' file
Is my understanding that by changing the hosting rewrites section of my firebase.json I could achieve this at least for new sessions (I suspect this won't 'kick out' current users to this page). But the thing with this approach is that i need to redeploy my whole project for the firebase.json file on server to be overwritten with the local one that has the rewrite. Inverse action should also be performed when the maintenance is finished, for the original firebase.json file, generating a second deploy.
The ideal for me would be to have a Cloud Function for example, that i could call via http or when clicking a button in a section of my Angular app, that would trigger the behavior described at the beginning. Calling this same function when maintenance ends, setting a param such as 'maintenanceFinished' = true to get things back to normal.
Has anyone implemented something like this or can point me in the right direction? Let me know your thoughts, thanks!!
Nicolas