Skip to content
RolloutDocs
NL
5Go-live, step by step· step 5 of 7

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.

With the server gateway
Step 0 / 6
Employeebooking link
Rollout serverknows the secret
Databaseonly knows the hash
Someone elsedirectly on the API
Opens booking link
Free slots?x-rollout-gateway
↻ Hash matches
Slots
Directly, with a fake IP
Only reachable via Rollout

Scroll here or press play.

What the gateway protects:

WhatWithout gatewayWith gateway
Booking link, client portal, feedbackCallable directly with a made-up IPOnly via your server
Limit on failed attempts per IPBypassable, and abusable to block someone elseOnly counts the real IP
Starting and finishing a change planAn engineer could "finish" a plan with made-up resultsOnly the server records results

Turn it on in five steps

Order (no downtime)
  1. 1
    Migration 0017
    changes nothing yet
  2. 2
    Create secret
    on your own computer
  3. 3
    In Vercel + deploy
    Sensitive, Production
  4. 4
    Hash in database
    now the gateway is on
  5. 5
    Check
    gateway: ok
  1. Run migration 0017

    If you ran all migrations in step 1, this is already done. Otherwise: ./deploy/migrate.sh or supabase/setup-0017.sql in the SQL Editor. As long as no hash is set, everything works as before.

  2. Create the secret

    On your own computer, in the repository folder:

    Terminal
    $ node scripts/gateway-secret.mjs
    ROLLOUT_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.

  3. Put the secret in Vercel and deploy

    Settings → Environment Variables → ROLLOUT_GATEWAY_SECRET, Production only, Sensitive on.

    Vercel → project → Settings → Environment Variables
    EnvironmentsProductionPreviewDevelopment
    No variables saved yet

    Then Deployments → Redeploy. Check https://<your-domain>/api/ready: it should now say "gateway": "not-enforced" (secret present, gateway not on yet).

  4. Put the hash in the database

    Paste the update line from the script into the SQL Editor and click Run. From this moment the gateway is on.

    Supabase → SQL Editor → New query
    Untitled query
    1
    2
    3
    ResultsNothing run yet
  5. 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/readyMeaningWhat to do
okSecret matches, gateway is onNothing
not-enforcedSecret is on the server, but there's no hash in the database yetDo step 4
mismatchSecret and hash don't belong together. Booking links do not workRun the script again and set both values
missing-secretNo (valid) secret on the serverDo step 3; the secret must be at least 32 characters
Emergency switch

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.

Turn on the server gateway · Rollout Docs