Turn on the server gateway
Booking links, the client portal and "one-click fix" go through your Rollout server. With the server gateway, the database only accepts those requests if they really come from that server. It takes five minutes and no downtime.
Why this is needed
The database lives at Supabase and, like any cloud database, is reachable over the internet. Without the gateway, someone could call the public functions directly, bypassing Rollout, and make up an IP address while doing so. With the gateway, your server sends a secret key along. Anyone without that key is refused.
Scroll here or press play.
What the gateway protects:
| What | Without gateway | With gateway |
|---|---|---|
| Booking link, client portal, feedback | Callable directly with a made-up IP | Only via your server |
| Limit on failed attempts per IP | Bypassable, and abusable to block someone else | Only counts the real IP |
| Starting and finishing a change plan | An engineer could "finish" a plan with made-up results | Only the server records results |
Turn it on in five steps
- 1Migration 0017changes nothing yet
- 2Create secreton your own computer
- 3In Vercel + deploySensitive, Production
- 4Hash in databasenow the gateway is on
- 5Checkgateway: ok
- Run migration 0017
If you ran all migrations in step 1, this is already done. Otherwise:
./deploy/migrate.shorsupabase/setup-0017.sqlin the SQL Editor. As long as no hash is set, everything works as before. - Create the secret
On your own computer, in the repository folder:
Terminal$ node scripts/gateway-secret.mjsROLLOUT_GATEWAY_SECRET=f3Q9xK2vT7pL1mN8rB4wY6zH0cJ5sD2aE9uG4kR1tV8-- Supabase SQL Editor (pas NA het deployen van de server met dit geheim):update platform_settings set gateway_secret_hash = '6b1f…c9e2';The script gives two things: the secret (for Vercel) and an SQL line with the hash (for the database). Each run gives a new secret, so use both from the same run. The values above are examples.
- Put the secret in Vercel and deploy
Settings → Environment Variables →
ROLLOUT_GATEWAY_SECRET, Production only, Sensitive on.Vercel → project → Settings → Environment VariablesEnvironmentsProductionPreviewDevelopmentNo variables saved yetThen Deployments → Redeploy. Check
https://<your-domain>/api/ready: it should now say"gateway": "not-enforced"(secret present, gateway not on yet). - Put the hash in the database
Paste the
updateline from the script into the SQL Editor and click Run. From this moment the gateway is on.Supabase → SQL Editor → New queryUntitled query123ResultsNothing run yet - Check
Then open a booking link in a private window: it should just work. And a direct call should now be refused ("Deze functie is alleen via Rollout bereikbaar" means "this function is only reachable via Rollout"):
Terminal$ curl -s https://<project-ref>.supabase.co/rest/v1/rpc/resolve_booking_token -H 'apikey: <anon-key>' -H 'Content-Type: application/json' -d '{"token":"bk_test"}'{"code":"P0001","details":null,"hint":null,"message":"Deze functie is alleen via Rollout bereikbaar."}
What does the status mean?
gateway in /api/ready | Meaning | What to do |
|---|---|---|
ok | Secret matches, gateway is on | Nothing |
not-enforced | Secret is on the server, but there's no hash in the database yet | Do step 4 |
mismatch | Secret and hash don't belong together. Booking links do not work | Run the script again and set both values |
missing-secret | No (valid) secret on the server | Do step 3; the secret must be at least 32 characters |
Booking links stopped working after turning it on and you can't fix it right away? Turn the gateway off with update platform_settings set gateway_secret_hash = null; in the SQL Editor. Everything works as before again. Then calmly find out what went wrong.
Replacing the secret
On suspicion of a leak, or when someone with access leaves: run the script again, put the new secret in Vercel, deploy, and set the new hash in the database. Between the deploy and the new hash, booking links briefly fail; so do it outside office hours.
Every installation (every MSP) has its own secret. Never reuse it.