Architecture
Apps and Repositories
Projects and apps
Section titled “Projects and apps”A project is the backend: the database, auth, storage, realtime and functions. An app is something that talks to it.
| Type | What it is |
|---|---|
backend |
The tables, hooks and functions that define the API. Exactly one per project. |
static |
A built client bundle — an SPA or static site, served at its own path, or on a hostname of its own. |
That is the whole list. The admin panel is a static app like any other: it is
built in your repository, with your frontend/src/cms customizations, which is
why custom fields and custom views work in it on day one.
Who owns the server process is a property of the backend, not a separate app type:
runtime |
What it means |
|---|---|
managed |
The platform’s runtime image runs your bundle. You supply tables, functions, crons and schema. |
custom |
You supply the server: your own Dockerfile and entrypoint. rebase eject sets this up. |
This is independent of where it runs. Both run on Corabase Cloud and both
self-host — the destination lives in .rebase/cloud.json, not in the manifest.
The important part is what owns the list. A repository declares only the apps it contains; the project owns the set of apps that exist. Two repositories never need to know about each other — they only need to know the project. That is what makes a separate frontend repository, or a mobile app with no repository relationship at all, an ordinary thing rather than a special case.
rebase.json
Section titled “rebase.json”The manifest declares topology, and nothing else. Schema, security rules, hooks and functions stay in TypeScript where a type system can check them.
{ "rebase": "^1", "apps": { "backend": { "type": "backend", "runtime": "managed" }, "site": { "type": "static", "root": "frontend", "build": "npm run build --workspace frontend", "output": "frontend/dist", "path": "/" }, "admin": { "type": "static", "root": "admin", "build": "npm run build --workspace admin", "output": "admin/dist", "path": "/admin", "cms": "/admin" } }}One process serves all of it: the API at /api, the site at /, the admin at
/admin. That is the self-hosting story, and a perfectly good small tier on
Corabase Cloud.
A static app’s path takes one of two forms:
path |
Where the app answers |
|---|---|
"/", "/admin" |
At that path, on every hostname the project is served on. |
"https://www.example.com", "https://admin.example.com/cms" |
Only on that hostname, at the path after it. See An app on its own hostname. |
The URL form is how a project with one site per domain, such as one Vercel or Netlify project per domain, becomes one Corabase project: one static app per hostname, all served by the same deploy.
Saying where the CMS is
Section titled “Saying where the CMS is”cms is the URL path where an app mounts <RebaseCMS>. It is optional, it is
the one field here that describes what is inside an app rather than where the
app lives, and it exists because nothing else can find that out.
The CMS is a React component in your own frontend, so its address is a
client-side route. It is not a server route, not a file in the build, and not
distinguishable from any other unmatched path under a SPA — a request to
/admin gets the same index.html as a request to /anything-else. So no
deploy, no running server and no amount of probing can tell where your admin
panel is. If you do not write it down, nothing knows.
What knows it, does something with it:
- Corabase Cloud puts an Open CMS link in the project header and lists the
address on the project’s overview — on the app’s own hostname when it has
one. Without
cms, the console can offer only the project host — which reaches the CMS only if the CMS happens to sit at the root of it. rebase devprints the CMS URL in its startup banner when it is not simply the frontend’s home page.rebase apps listshows it beside the app that serves it.
Three shapes, and all of them are ordinary.
// The whole app is the CMS — what `rebase init` scaffolds."admin": { "type": "static", "root": "frontend", "output": "frontend/dist", "path": "/", "cms": "/" }
// The CMS is one route of a bigger app, sharing its session and its client."web": { "type": "static", "root": "frontend", "output": "frontend/dist", "path": "/", "cms": "/admin" }
// The CMS is an app of its own, on a hostname of its own — see the next section."admin": { "type": "static", "root": "admin", "output": "admin/dist", "path": "https://admin.example.com", "cms": "/" }The value is the path you would type after the hostname, not a path relative
to path, and it has to be inside the app declaring it — that app’s SPA
fallback is what answers there. It is always a path, even when the app’s path
is a URL: the CMS is then at that path on the app’s hostname, so "cms": "/"
above means https://admin.example.com/. A project has one CMS; declaring a
second is an error rather than a coin toss over which one the console links to.
path is a build-time input as well as a serving one. An app mounted at
/admin has to be built for /admin, or index.html loads and every asset
404s — a blank page with no error anywhere. rebase build passes the value as
REBASE_APP_BASE, which your bundler reads as its base path:
// vite.config.tsexport default defineConfig({ base: process.env.REBASE_APP_BASE ?? "/", // …});and refuses to ship a build that ignored it.
An existing project does not need one. The CLI infers the same layout from the
directory structure, and rebase apps init writes it down when you want it
explicit:
rebase apps list # what this repository contributesrebase apps init # write an inferred rebase.jsonInference cannot know two things a scaffold’s rebase.json declares. It names
the static app web, where a scaffold names it admin, and it cannot know the
app’s cms route. The name does not change: Corabase Cloud registered web for
every project that deployed without a rebase.json.
rebase apps init --force keeps the names, path, cms, routes,
frameAncestors, redirects and cleanUrls of the apps the file it replaces
declares, and names an app it no longer finds as removed.
An app on its own hostname
Section titled “An app on its own hostname”path can also be a full https:// URL, which gives the app a hostname of its
own:
{ "rebase": "^1", "apps": { "backend": { "type": "backend", "runtime": "managed" }, "web": { "type": "static", "root": "frontend", "build": "npm run build --workspace frontend", "output": "frontend/dist", "path": "/" }, "admin": { "type": "static", "root": "admin", "build": "npm run build --workspace admin", "output": "admin/dist", "path": "https://admin.example.com", "cms": "/" } }}https://admin.example.com serves admin. Every other hostname the project
answers on — example.com, or the project’s own address on Corabase Cloud —
serves web, and admin is not reachable there at all. It is still one
process and one deploy; the hostname only decides which app answers a request.
Two rules decide it:
- An app with a hostname answers only on that hostname. An app without one answers on every hostname.
- Of the apps left, the one with the longest path wins, as it always has. At an equal path, the app that names the hostname wins over the one that does not.
In the example both apps are at /, so on admin.example.com the second rule
picks admin. Declare the admin at "https://admin.example.com/cms" instead
and it answers only under /cms on that hostname: admin.example.com/pricing
goes to web. A hostname narrows where an app answers; it does not hand the
app everything on that hostname. No two apps may share both a hostname and a
path.
The backend is not an app, and a hostname does not move it. /api, /health
and the other paths the backend reserves are answered before any app is
consulted, on every hostname, so https://admin.example.com/api is the same
API as https://example.com/api. An app that calls its own origin — the
scaffold’s empty VITE_API_URL — needs no API URL of its own and no CORS
setting. For the same reason those paths are refused after a hostname just as
they are on their own: https://admin.example.com/api is no more valid than
/api.
Everything else about path applies to the part after the hostname. The app
is still built for it: https://admin.example.com is built with
REBASE_APP_BASE set to /, https://admin.example.com/cms with /cms/, and
a bundler that ignores it still gives you a blank page. cms is a path on the
app’s hostname, inside that path part. The URL must be https:// and carry a
hostname and a path and nothing else — no port, query or fragment. A bare
admin.example.com is refused, with the URL it should have been.
Under rebase dev, nothing is routed by hostname. It runs the app in
frontend/ at the root of a localhost port, as it always has, and for an app
with a hostname its banner also prints the https:// address it will have
once deployed.
rebase start is different, because it runs the built bundle through the same
runtime a deployment does — hostname routing included. An app with a hostname
answers only to requests whose Host is that hostname, so
http://localhost:3001/ shows the app without one, and a bundle whose only app
names a hostname answers 404 there. To reach it locally, send the header
yourself:
curl -H "Host: admin.example.com" http://localhost:3001/or point the hostname at 127.0.0.1 in /etc/hosts and open
http://admin.example.com:3001/. There is deliberately no query parameter or
header that overrides the routing: one that worked locally would also work
against a deployment, and choosing the app by anything but the real Host is
what the routing exists to prevent.
Self-hosted, the process makes the same choice from each request’s Host
header. Pointing the hostname at the server and giving it a certificate are
yours to do, as they are for the project’s main hostname, and a reverse proxy
in front has to pass the original Host through — Caddy does by default,
nginx needs proxy_set_header Host $host;. X-Forwarded-Host is not read,
because any client can send one.
On Corabase Cloud
Section titled “On Corabase Cloud”rebase cloud deploy registers the hostname on the project — what
rebase cloud domains add does — so there is no separate step to forget. What
happens next depends on DNS:
- The records already exist. The deploy verifies the hostname, and it is live when the deploy finishes.
- They do not. The deploy goes ahead, and prints the two records to create: a TXT record that proves the name is yours, and a CNAME that points it at the project (an A record, if the hostname is the domain’s apex).
Once the records are published:
rebase cloud domains verify admin.example.comrebase cloud domains list prints the records again if you lose them. A
hostname that is not verified within 7 days of being registered is released,
and the next deploy registers it again. When
verification passes, the platform issues the HTTPS certificate for the
hostname; there is nothing to upload. Until then admin answers nowhere, since
the one hostname it answers on does not reach the project yet — the rest of
the project is live either way.
The console follows the app onto its hostname: the Open CMS link and the CMS
address on the project’s overview are https://admin.example.com/, not the
project host.
A hostname that another project has verified fails the deploy before anything
rolls out, and so does one under the platform’s own domain. One that another
project registered and never verified does not stand in your way: the refusal
gives you a TXT record for your project, and once it exists the next deploy (or
rebase cloud domains add) takes the hostname. Adding a hostname
the project does not have yet changes the project’s domains, which an access
token made with --can deploy may not do: from CI, add the hostname once with
rebase cloud domains add while signed in, and the token then deploys it like
any hostname already on the project. Taking the app out
of rebase.json leaves the hostname registered on the project; remove it with
rebase cloud domains remove admin.example.com.
A hostname belongs to an app, not to a route
Section titled “A hostname belongs to an app, not to a route”A hostname is given to a whole app. It cannot point at a route inside one. When
the CMS is one route of a single SPA — web at / with "cms": "/admin" — it
lives at /admin, on every hostname the project answers on. Giving that app
https://admin.example.com would move the whole SPA there, with the CMS still
at /admin under it. To give the CMS a hostname of its own, make it an app of
its own, with its own build, as in the example above.
Serving a function at a path on an app
Section titled “Serving a function at a path on an app”A custom function answers at /api/functions/<name>, and a static app cannot
claim /api. A publishing site needs some paths that no build can hold — a
sitemap and a feed that list the latest posts, a page rendered from the
database. routes serves a function’s response at a path on the app’s own
address:
"site": { "type": "static", "root": "site", "output": "site/dist", "path": "https://www.example.com", "routes": [ { "path": "/sitemap.xml", "function": "sitemap" }, { "path": "/feed.xml", "function": "feed" }, { "path": "/blog/*", "function": "blog" } ]}https://www.example.com/sitemap.xml is then whatever functions/sitemap.ts
returns, with its own Content-Type, status and headers. Everything else on
the hostname is the site’s build, as before.
- Exact or wildcard.
/sitemap.xmlmatches that path alone./blog/*matches/blogand every path beneath it, and hands the function the rest:/blog/helloreaches the function’s/:slugroute withslugset tohello, and/blogreaches its/route. - The function sees an ordinary call. The request reaches it as if it had
been made to
/api/functions/<name>, through the same auth, scope checks, rate limit and timeout. Its method, headers, body and query string pass through, and so doesHost, sonew URL(c.req.url).originis the site’s origin — what a sitemap’s absolute URLs are built from. The function still answers at/api/functions/<name>too. - The most specific route wins: an exact path before any wildcard, and a
longer wildcard before a shorter one. A route also wins over a file of the
same path in the build, so a stale
public/sitemap.xmlcannot hide it. - Only where the app answers. A route applies to requests the app itself
would answer — on its hostname, if it has one, and not under another app’s
path.
rebase.jsonis refused when a route sits where another app answers. - Inside the app, and never the backend’s. A route’s path is absolute,
inside the app’s
path, and cannot be under/api,/health,/healthz,/livez,/readyzor/metrics, nor have a segment starting with.. A wildcard cannot cover the whole app, which would leave its build unserved.
Routes are served by the backend process the app is folded into, because that
is where the functions run: rebase build and rebase cloud deploy fold every
static app into the backend’s bundle, and the build fails if a route names a
function the backend does not have. A static app deployed on its own has no
functions to call, so rebase cloud deploy refuses one with routes, and the
runtime refuses to boot a static-only bundle that declares them.
A routed response that sends no Content-Security-Policy gets the app’s own,
so the origins in its frameAncestors
can frame a server-rendered page as they can frame the rest of the site.
Under rebase dev the app is served by its own dev server, which knows nothing
of the routes; call the function at /api/functions/<name> there, or try the
routes against a build with rebase start.
Redirects and clean URLs
Section titled “Redirects and clean URLs”A static app takes redirects ({ "from": "/blog/:slug", "to": "/posts/:slug" },
including to another domain) and cleanUrls: true (/x serves x.html). See
Redirects and clean URLs, which
also maps a vercel.json onto rebase.json.
App Links, Universal Links and other /.well-known files
Section titled “App Links, Universal Links and other /.well-known files”Android App Links and iOS Universal Links are verified by fetching a file from
the site’s origin: https://<host>/.well-known/assetlinks.json and
https://<host>/.well-known/apple-app-site-association. Until a platform can
fetch it, a tapped or scanned link opens in the browser instead of the
installed app. Put the files in the build’s .well-known/ folder (with Vite,
public/.well-known/) and the app at / serves them:
site/dist/ index.html .well-known/ assetlinks.json apple-app-site-association- A file or a 404.
/.well-known/<name>answers with that file of the build, or 404 when the build has none, never the app’sindex.htmland never a redirect. Files ending in.jsonand the extensionlessapple-app-site-associationare sent asapplication/json; others by their extension (security.txtastext/plain). Each carries anETagandCache-Control: no-cache. - The backend’s documents win.
jwks.json,oauth-protected-resource,oauth-authorization-server,openid-configurationandacme-challenge/are never served from a build, even in a process where the backend does not serve them itself, so a build cannot publish signing keys or OAuth metadata. - No other dot-file. A segment starting with
.beneath.well-known(/.well-known/.secret), and every other dot path (/.env,/.git/config), are still refused, encoded or not, and a file that is a symlink out of the build is not served. - Only the app at
/./.well-knownbelongs to the origin, so an app under a path (/admin) publishes nothing from its.well-known/folder. With apps on their own hostnames, each hostname’s app at/serves its own, soadmin.example.comandwww.example.comcan publish different files.
The files are served by the backend process the app is folded into
(rebase start, a self-hosted or Cloud deployment), as the rest of the build
is. A route’s path cannot be under /.well-known; to generate one of these
documents, write it into the build.
Building and deploying apps
Section titled “Building and deploying apps”rebase build # every app in this repositoryrebase build backend # just the bundlerebase build admin # just that app's static assetsThe backend builds first, because a client app’s build may consume an SDK generated from its tables.
Multiple repositories
Section titled “Multiple repositories”The monorepo stays the default: one repository with a backend and an admin panel
is the simplest thing that works, and rebase init scaffolds it. Splitting up is
the graduation step, not a requirement.
In a separate frontend repository you need two things — a manifest declaring what this repository contributes, and a link to the project:
// rebase.json{ "rebase": "^1", "apps": { "marketing": { "type": "static", "root": ".", "build": "npm run build", "output": "dist" } }}rebase cloud link https://api.example.com # a self-hosted projectrebase cloud link # or pick a Corabase Cloud projectThe link is written to .rebase/cloud.json and is not committed — it is
per-checkout, like a git remote. The manifest is committed; the link is not.
Typed clients without the tables
Section titled “Typed clients without the tables”This is the mechanism that makes multi-repo work. A repository that contains no tables generates its typed SDK from the project itself:
rebase generate-sdk --from linkrebase generate-sdk --from https://api.example.com --token $REBASE_SERVICE_KEYThe CLI fetches /api/meta/contract and reads its tables — the compiled
descriptors, relation targets included, which the type generator needs to
decide whether a foreign key is a string or a number — and emits exactly the
same output it would have produced from local source.
The contract endpoint needs the schema:read scope, which an admin holds. It
describes every table,
column and relation in the project, including ones no security rule would ever
expose; that is a map of the database, not public API documentation.
Detecting drift
Section titled “Detecting drift”Splitting repositories costs you one thing worth naming: a schema change and the frontend that uses it no longer land in the same commit. The backend can deploy a change that strands a client built against the old shape.
Every generated SDK records the schema it came from:
// generated/sdk/schema.meta.ts — generatedexport const SCHEMA_VERSION = "v1:c5d97d0f96b7f87a";And every project publishes its current one, without authentication, because a version stamp reveals nothing about the schema it stands for:
curl -s https://api.example.com/api/meta/schema-version# {"schemaVersion":"v1:c5d97d0f96b7f87a","runtime":{"version":"0.38.1","contract":1}}Comparing the two in CI turns a silent mismatch into a failed check. The stamp changes when the generated types could change — a new property, a changed relation — and deliberately not when a hook, a security rule or an icon changes, so it does not cry wolf.
Client configuration
Section titled “Client configuration”rebase apps config webPrints what a client needs to reach the project. It never prints a secret: the
API URL and an app’s publishable identity are meant to ship inside a client
bundle, and anything that is not safe there does not belong in output that will
end up in a committed .env.
Related
Section titled “Related”- Runtime & Bundles — what
rebase buildproduces and what boots it - Split Processes — running one bundle as several processes
- CLI Commands —
rebase appsand the rest