Bento Spaces documentation
17 — Split deployment
Bento Spaces is deployed as separate instances, not one IIS site answering for five hostnames. The shell is static, the API owns the data, and each future surface gets its own release cadence and failure boundary. The UI hosts call the API directly; they do not carry a copy of /api.
bentospaces.com ───────────────┐ coming-soon root, app at /preview, /docs, /developer
www.bentospaces.com ───────────┤ 301-only site
developer.bentospaces.com ─────┤ static Studio (config.js → API base)
manage.bentospaces.com ────────┼──> api.bentospaces.com ──> App_Data
marketplace.bentospaces.com ───┤ static catalog + widget files
status.bentospaces.com ────────┘ static status page
bentospaces.com/docs and bentospaces.com/developer are static pages on the web host. Serve those two routes before any SPA fallback; they are paths, not extra origins. The apex root is a coming-soon page; the live app is at /preview until launch. www.bentospaces.com is a 301-only site to the apex. staging.bentospaces.com is the pre-release UI; it needs its own API and storage (never production customer data), and status.bentospaces.com is a static status page. Neither staging nor status is an origin in the production CORS allowlist. Status and staging still need their IIS bindings and certificates; see Domain cutover and certificates.
Deployables
| Deployable | What ships | How |
|---|---|---|
| web | release/htdocs (source: web/) — coming-soon root, the app at /preview, HTML/CSS/JS/icons/manifest, and the generated /docs + /developer pages | any static host (IIS site, Caddy, CDN) |
| api | release/api — ASP.NET Core service | IIS app / Kestrel service behind the proxy |
| studio | release/developer (source: studio/) — manifest validator + preview | static host; config.js points at the API |
| manage | release/manage — operator console | static host; config.js points at the API |
| marketplace | release/marketplace — catalog, registry.json, widget manifests | static host (Caddy, IIS, CDN) |
| status | release/status (source: status/) — static status and incident page | static host |
| www | release/www — redirect-only IIS site | separate IIS site bound to www.bentospaces.com |
./scripts/publish-split.sh
# release/htdocs release/api release/developer release/manage
# release/marketplace release/status release/www
Every static artifact gets a web.config that forces HTTPS and adds basic security headers; it needs the IIS URL Rewrite module. release/www uses IIS httpRedirect instead and must be a separate site pointed at release/www, never at release/htdocs.
/docs is generated from docs/*.md by scripts/build-docs.mjs during the split build. /developer is a static landing page in web/developer/; the working Studio stays on developer.bentospaces.com.
release/api ships with Hosts:ServeShell=false in its appsettings.Production.json, so the API host cannot serve the app shell. It carries only wwwroot/index.html for the /v and /display view endpoints. The old ./scripts/publish.sh still produces the single-host site (shell + API together) for the current local deployment; the split script is the path forward.
Each static artifact gets a config.js:
window.BENTO_API_BASE = "https://api.bentospaces.com";
That is the only deployment-specific value in the UI. Set BENTO_API_BASE when publishing for staging or a different API host. No /api route exists on the UI hosts; the browser calls the API origin directly.
API configuration
The API serves no shell in this mode. The split build writes these defaults into release/api/appsettings.Production.json, and web.config sets ASPNETCORE_ENVIRONMENT=Production so a Development appsettings file cannot silently bring back localhost origins or fake billing. Override any value with the equivalent environment variable when needed:
Hosts__ServeShell=false
Hosts__Origins__0=https://bentospaces.com
Hosts__Origins__1=https://developer.bentospaces.com
Hosts__Origins__2=https://manage.bentospaces.com
Hosts__Origins__3=https://marketplace.bentospaces.com
Auth__CookieDomain=.bentospaces.com
# Auth__CookieName=bento_sid # staging must use a distinct name
Hosts__RequireKnownOrigin=true
Hosts__TrustForwardedHeaders=true
Marketplace__Url=https://api.bentospaces.com/api/market/registry.json
Marketplace__StaticBase=https://marketplace.bentospaces.com/
Manage__Token=<long random string>
Manage__Operators__0=ren
Billing__Provider=paddle
Billing__Paddle__ApiKey=<paddle api key>
Billing__Paddle__WebhookSecret=<paddle webhook secret>
Billing__Paddle__PriceIdPlus=pri_<plus price>
Billing__Paddle__PriceIdPublisher=pri_<publisher price>
Billing__Paddle__ApiBase=https://api.paddle.com # https://sandbox-api.paddle.com in testing
OAuth__RedirectBase=https://bentospaces.com
OAuth__Providers__google__ClientId=<oauth client id>
OAuth__Providers__google__ClientSecret=<oauth client secret>
OAuth__Providers__google__AuthorizationUrl=https://accounts.google.com/o/oauth2/v2/auth
OAuth__Providers__google__TokenUrl=https://oauth2.googleapis.com/token
OAuth__Providers__google__BaseUrl=https://gmail.googleapis.com
OAuth__Providers__google__Scopes__0=https://www.googleapis.com/auth/gmail.readonly
Push__Subject=https://bentospaces.com
- ServeShell=false — static files and the SPA fallback are off; the API host serves
/api - plus the
/vand/displayshell for read-only sessions. - Origins — the exact UI origins, written into
appsettings.Production.jsonby the split - build. The browser calls the API cross-origin, so CORS and the mutation guard use this
- list; no wildcard. Every host that loads the UI belongs here:
https://bentospaces.com,https://developer.bentospaces.com,https://manage.bentospaces.com,https://marketplace.bentospaces.com.- CookieDomain —
.bentospaces.com, written intoappsettings.Production.json, so the same - HttpOnly session is shared by the apex, Studio and Manage. Cookies are
Secureand SameSite=Lax; the UI hosts are same-site. The operator console signs in with a normal- account session. A staging deployment on the same parent domain sets a distinct
Auth__CookieName(and.staging.bentospaces.com) so its cookie cannot overwrite the- production session.
- RequireKnownOrigin — a browser mutation whose
Originis not on the list is refused - with
403 origin_not_allowed, before it can touch a session. Requests without anOrigin - (curl, server-to-server) are unaffected.
- TrustForwardedHeaders — honours
X-Forwarded-For/-Protofrom the proxy so cookies are - marked
Secureand throttling sees the real client IP. - Marketplace__Url — the live WidgetMarket registry the API serves; it merges Studio releases
- with the seeded legacy examples. Without it, the in-app marketplace asks for a registry URL
- once and stores it on the device.
- Marketplace__StaticBase — where the legacy example manifests and other static marketplace
- files live. The API only stores its
MarketSeedread model. - Push__Subject — VAPID contact, a
mailto:or https URL. With no mailbox yet, production - uses
https://bentospaces.com; swap it for amailto:when email exists. The VAPID key pair is generated - on first use under
App_Data/private/push/vapid.json; back it up, because rotating it - invalidates every browser subscription. Push__Transport is
webpushon a real host and - defaults to
fakeon disposable storage, where encrypted bodies are recorded instead of sent. - Billing__Provider —
noneby default,fakeorpaddle.fakeis accepted only when - storage is disposable (
/api/healthtest: true); the real host must usepaddle. - BillingPaddleApiKey — the Paddle API key. It stays on the server; the browser only
- receives the hosted checkout URL and a short-lived portal link. The key needs
price.read(Verify prices),transaction.write(checkout),customer_portal_session.writeandsubscription.read(portal and renewal context).- BillingPaddleWebhookSecret — Paddle's webhook secret, used to verify
Paddle-Signature(HMAC-SHA256 over{ts}:{raw body}, five-minute window).- BillingPaddlePriceIdPlus / PriceIdPublisher — the Paddle price id per plan. A
- missing price is a
422 checkout_invalid, not a silent free upgrade. - BillingPaddleApiBase —
https://api.paddle.com, orhttps://sandbox-api.paddle.com - while testing. BillingPaddleVersion overrides the
Paddle-Versionheader (default 1).- Billing__WebhookSecret — the shared secret for the fake provider's
X-Billing-Secret; - ignored when a Paddle secret is set. Point Paddle's notification destination at
/api/billing/webhookand subscribe to allsubscription.*events. At minimum:subscription.created,subscription.updated,subscription.canceledandsubscription.past_due; the API ignores non-subscription events.
Before switching a host to live, sign in to /manage: the Billing card shows the provider, sandbox vs live, whether the key and webhook secret are set, both price ids and how many subscriptions and events have been seen. Verify prices asks Paddle whether each price id exists, so a typo fails before a customer reaches checkout. The account, catalog, key and webhook steps are in Paddle sandbox runbook.
OAuth providers — each provider is a config block under OAuth__Providers__{id}. The redirect URI must be registered with the provider exactly as {origin}/api/connectors/oauth/callback; set OAuth__RedirectBase when Bento Spaces is behind a proxy so the value matches. BaseUrl is the API origin (https://gmail.googleapis.com), because connector paths are absolute. AuthorizationUrl may carry extra parameters as AuthorizationParams (Google needs access_type=offline and usually prompt=consent). A provider with a missing client id or URL is simply not listed.
- Manage__Operators — usernames allowed to use
/api/manage/*with a browser session. Manage__Tokenremains for automation viaX-Manage-Token; unset both and the endpoints are- hidden. A wrong machine token is
401, a signed-in non-operator is403.
Keep SameSite=Lax and HttpOnly; the API still refuses * with credentials.
Bento Bridge
The bridge is a separate ASP.NET process (source/Bento.Bridge) on the LAN. It never needs a Bento Spaces account; it holds one bearer token and, optionally, a pairing code:
ASPNETCORE_URLS=http://+:8481
BRIDGE_API_TOKEN=<long random string>
BRIDGE_PUBLIC_URL=http://bento-host:8481 # the URL Bento will store
BRIDGE_CONFIG=/data/devices.json
BENTO_URL=https://bentospaces.com # only when self-registering
BENTO_PAIRING_CODE=ABCD-EFGH # one-time, from Settings → Connectors
- Token is what Bento Spaces sends as
Authorization: Bearer; the same value must be in the - connector. Pairing delivers it, so do not paste the bridge's token into Bento Spaces by hand.
- Pairing posts to
{BENTO_URL}/api/connectors/paironce at startup. A failure only logs; - the bridge still serves
/api. The code expires in ten minutes and works once. - If the token is empty while pairing, the bridge generates one for that run and logs it; pin
- it in
.envso a restart keeps the same connector working. - Never publish port 8481 on a raw public IP. Put the bridge behind Tailscale or a Cloudflare
- Tunnel; the generated stack can add a
cloudflaredservice.
Caddy
deploy/Caddyfile contains the static and API blocks. The important part:
bentospaces.com {
root * /srv/bento/htdocs
handle /v/* { reverse_proxy 127.0.0.1:5080 }
handle /display/* { reverse_proxy 127.0.0.1:5080 }
file_server
}
api.bentospaces.com {
reverse_proxy 127.0.0.1:5080
}
The UI calls https://api.bentospaces.com directly; there is no /api handle on the shell. config.js supplies the API origin. CORS and the .bentospaces.com cookie make the session work across the subdomains.
Share links (/v/…) and display pairing (/display/…) are the one exception: they are entry points on the apex that need the API to set the read-only session and return the shell, so they are proxied there. That gateway carries no /api surface.
IIS alternative
- One static site for
bentospaces.compointing atrelease/htdocs. - One application/site for
api.bentospaces.compointing atrelease/api. release/htdocs/config.js,release/developer/config.js,release/manage/config.jsandrelease/marketplace/config.jspoint at the API. No/apirule is needed on the UI sites.- No UI
web.configships by default. Share/display are the only paths that need a view gateway; - add one only if you use them (Caddy handles it directly, IIS would need URL Rewrite for
/v/*and/display/*). The API itself is not proxied.- Separate app pools. The API pool runs the automations runner; static sites do not.
web.configfor the API:ASPNETCORE_ENVIRONMENT=Productionplus the variables above.- TLS per host; no shared pool between
manageand the API.
Domain cutover and certificates
All public names currently resolve to the same IIS host (80.64.211.241). Each one still needs its own SNI binding and certificate:
| Host | IIS site root | Certificate |
|---|---|---|
bentospaces.com | release/htdocs | apex (+ www) |
www.bentospaces.com | release/www | the same certificate, separate redirect site |
api.bentospaces.com | release/api | API host |
developer.bentospaces.com | release/developer | Studio host |
manage.bentospaces.com | release/manage | operator host |
marketplace.bentospaces.com | release/marketplace | catalog host |
status.bentospaces.com | release/status | status host |
staging.bentospaces.com | staging UI only | staging host |
status.bentospaces.com and staging.bentospaces.com currently fall through to an expired publish.releasefor.com certificate. That means their SNI bindings are missing or point at the wrong site. Add the hostname binding, issue/renew the certificate (win-acme or the hosting panel), and confirm with:
openssl s_client -servername status.bentospaces.com -connect status.bentospaces.com:443 \
</dev/null 2>/dev/null | openssl x509 -noout -subject -dates
www is a separate site: bind www.bentospaces.com to release/www, not to htdocs. Its web.config 301s every path to https://bentospaces.com/, so both HTTP and HTTPS are handled without URL Rewrite.
Staging must not share the production session cookie. A cookie scoped to .bentospaces.com is sent to staging.bentospaces.com and to a staging API on the same parent domain. Give staging its own API host (for example api.staging.bentospaces.com), its own Auth:CookieDomain=.staging.bentospaces.com, and a distinct Auth:CookieName; otherwise a production sign-in and a staging sign-in can overwrite each other.
scripts/check-domains.sh audits TLS, HTTP-to-HTTPS redirects, the www 301, /docs, /developer, the Studio, Manage, Marketplace, the status page and the exact health payload.
Studio
studio/ is the developer workbench. The page is static, but publisher, drafts and releases need the API (/api/studio/*), so the host proxies /api exactly like the webtop:
node scripts/build-studio.mjs
API_UPSTREAM=http://127.0.0.1:5080 node scripts/serve-static.mjs studio 5085
See 18 — Studio.
Account recovery
The in-app path is Account → Change password: it asks for the current password, rewrites the PBKDF2 hash and revokes every other session while keeping the one that made the change.
If nobody can sign in, use the operator reset on the API host:
printf '%s' 'NewPassword123' | node scripts/reset-password.mjs --root /var/lib/bentospaces ren
It writes the same hash format, revokes all sessions for that account and never prints the password. The password is read from stdin, so it is not in the URL; avoid putting it in shell history on a shared machine.
Manage
manage/ is a small static console. Its config.js points at the API; the browser calls https://api.bentospaces.com directly with the .bentospaces.com session cookie. It is tabbed: Defaults, Publishers, Market, Reports, Suggested and Billing. The operator card and its Sign out control only appear after sign-in.
- The browser signs in with an account listed in
Manage__Operators; writes send the X-Manage-Session: 1CSRF header. Automation usesManage__TokenviaX-Manage-Tokenand- never enters the page. Development lists
ren; production sets the operator usernames. - Publishers are listed with their widget counts; changing a tier is immediate and the tier
- shows on store cards and store pages. Auto-publish does not gate on tier — the tier is a trust
- signal and a hook for later moderation.
- Market releases lists every publisher release with its state; the operator can delist,
- relist, pause or resume a version. These are the same flags Studio writes, so a moderation
- action never mutates the release bytes.
- Verification requests show the note, evidence links and decision history. Changing the tier
- records an approval; Reject clears the request with a reason and notifies the publisher.
- The store shows the trust badge immediately.
- Publisher status is
active,suspendedorbanned. Suspended/banned hides the personal and - market registries and blocks new releases; installed widgets keep working.
- Suggested is operator curation: pick built-ins and published releases for the store's
- Suggested category; the market index is invalidated immediately.
- Reports is the reader report queue. Resolve or dismiss a report; the reporter gets a
report-reviewednotification and the publisher is not told.- Saving writes
data/config/default-widgets.json. Existing accounts are untouched; their - library is theirs and they may remove every widget.
- The page is published as
release/manageand served atmanage.bentospaces.com(or:5084 - locally). With neither an operator list nor a machine token the API is hidden behind
404. - The operator session and the machine token are the two supported paths; see
- Security.
Marketplace
marketplace/ is a self-contained static site:
registry.json— generated bynode scripts/build-marketplace.mjsfrommarketplace/widgets/*.jsonbuiltins.json— the 21 built-in widgets, listed as Included in the catalogwidgets/*.json— the manifests; the installer hashes these bytes and validatesid/versionindex.html+app.js— catalog with search, sizes and permissions
The single-host dev server serves the static catalog at /marketplace (the csproj copies marketplace/ into wwwroot). The in-app WidgetMarket source points at the API's live registry instead: appsettings.Development.json uses /api/market/registry.json, with Marketplace:StaticBase pointing back at /marketplace/ for the legacy example files. So Studio releases appear in the app immediately after publishing, and the five seeded examples still install from their static URLs.
The public catalog site reads the same live registry directly: marketplace/config.js points at https://api.bentospaces.com, and /api/market/registry.json is the catalog. /builtins.json and the legacy widget manifests stay static. The generated registry.json remains the fallback when no API base is configured. The single-host dev server serves the catalog at /marketplace with the same-origin API.
Serve it standalone when you want the real host:
node scripts/build-marketplace.mjs
node scripts/serve-static.mjs marketplace 5084
In Bento Spaces: Settings → Widget sources → Add http://localhost:5084/registry.json. The browser E2E (node scripts/e2e/marketplace.e2e.mjs) starts its own static server.
Five addresses
Each surface has its own origin, locally and in production:
| Surface | Local | Production |
|---|---|---|
| webtop | http://localhost:5080 | https://bentospaces.com/ |
| api | http://localhost:5081 | https://api.bentospaces.com/ |
| studio | http://localhost:5082 | https://developer.bentospaces.com/ |
| marketplace | http://localhost:5083 | https://marketplace.bentospaces.com/ |
| manage | http://localhost:5084 | https://manage.bentospaces.com/ |
They are five distinct origins in both cases: separate ports locally, separate hostnames behind TLS in production. The webtop, Studio and manage proxy /api on their own origin; the API is also directly reachable at its own address.
www.bentospaces.com redirects to the apex. bentospaces.com/docs and bentospaces.com/developer are static paths on the webtop, not extra origins. staging.bentospaces.com mirrors the pre-release stack with its own storage, and status.bentospaces.com is static; they are not part of the five production origins above.
Local split mode
Two terminals, no client changes:
# API only (no shell)
Hosts__ServeShell=false dotnet run --project source/Bento.Api --urls http://127.0.0.1:5080
# static shell + same-origin /api proxy
node scripts/dev-split.mjs # http://localhost:5081
For all five at once:
# API on its own address
dotnet run --project source/Bento.Api --urls http://127.0.0.1:5081
# shell, studio, marketplace, manage
node scripts/build-studio.mjs
node scripts/build-marketplace.mjs
node scripts/dev-five.mjs
Then open http://localhost:5080 (webtop), :5081 (API), :5082 (Studio), :5083 (marketplace), :5084 (manage). scripts/dev-split.mjs is the minimal shell-only proxy if you do not need all five.
Smoke test
node scripts/split-smoke.mjs # shell + API boundary
node scripts/five-smoke.mjs # all five addresses answer with their own content
Starts an API with ServeShell=false and the proxy, then checks:
- the API returns 404 for
/but 200 for/api/health - the proxy serves the shell and the API through
/api - a CORS preflight from an allowed origin is accepted; an unknown origin gets no allow header
Hosts__RequireKnownOriginrefuses a hostileOriginon a mutation
Backups
scripts/backup-data.sh archives data/ and private/ from Storage:Root with a checksum; scripts/restore-data.sh <archive> --yes restores it after stopping the API and keeps a pre-restore copy. The release archive (scripts/backup.sh) is for the static artifacts, not the live data.
Release checklist
- Back up live data
BENTO_STORAGE_ROOT=/srv/bento-data ./scripts/backup-data.sh
- Build and publish the split artifacts
./scripts/publish-split.sh
The script runs the model tests, publishes web, studio, marketplace, manage and api, removes api/wwwroot, and calls scripts/verify-release.sh.
- Set production configuration
Storage__Rootoutsiderelease/Hosts__ServeShell=falseand the four origin allowlist entriesMarketplace__Url=https://api.bentospaces.com/api/market/registry.jsonMarketplace__StaticBase=https://marketplace.bentospaces.com/Manage__Operators(operator usernames),Manage__Token(automation) andAuth__CookieDomain- Point the data root at the backup (or restore):
BENTO_STORAGE_ROOT=/srv/bento-data ./scripts/restore-data.sh <archive> --yes- Restart the API, then run the smoke tests:
node scripts/five-smoke.mjs # local five-host
node scripts/split-smoke.mjs # shell + API boundary
- Check the live surfaces — webtop, API health, Studio, marketplace registry, manage.
- Rollback by stopping the API, restoring the latest data archive, and swapping the static
- roots back to the previous release directory.
scripts/verify-release.sh can be rerun at any time; it checks the static entries, the API DLL, the live-market seed and that no wwwroot ships with the API.
What is still missing
The live list is Open work. The immediate platform gap is the Manage admin session; billing, push, the publisher plan and analytics follow. API tokens are built.