How to disable site/deployment/auth temporarily? (Vercel)
I would like to have a "killswitch" to teporarily disable my site on Vercel. This is just a safety measure if anything goes wrong.
What would be the easiest way to do so? The only thing I found is the "Password protection", but it is not allowed for hobby projects.
It would be fine for me to have a way to disable the whole deployment as well.
Additionally, it would be nice to be able to disable sign in/sign up with NextAuth.js temporarily. Is there something easy one can do? The
session
callback does not allow return false
or null
, so even returning false
from the signIn
callback will still allow users with session to get authenticated.2 Replies
You could use the new Edge Config store from Vercel and redirect users to a maintenance page from the middleware.
This way you could dynamically disable the whole website or some specific routes.
The only cons is that you would have to read the store on every request matched by the middleware (which is really fast!), but it might increase the bill (you have 1 million free read with Pro, then it's 3$ per million)
https://vercel.com/docs/concepts/edge-network/edge-config/get-started
Vercel Documentation
Getting Started with Edge Config
You can get started with reading data from Edge Config within minutes by following this quickstart guide.
Thanks, @Tomsize ! I don't want to have this middleware slow down every request, but it made me realize I can just keep this file in my app and comment it out completely and then uncomment the file as soon as I need it.
I also chose a slightly different implementation that does not rely on the env vars/edge config: