Bento Spaces docs

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

DeployableWhat shipsHow
webrelease/htdocs (source: web/) — coming-soon root, the app at /preview, HTML/CSS/JS/icons/manifest, and the generated /docs + /developer pagesany static host (IIS site, Caddy, CDN)
apirelease/api — ASP.NET Core serviceIIS app / Kestrel service behind the proxy
studiorelease/developer (source: studio/) — manifest validator + previewstatic host; config.js points at the API
managerelease/manage — operator consolestatic host; config.js points at the API
marketplacerelease/marketplace — catalog, registry.json, widget manifestsstatic host (Caddy, IIS, CDN)
statusrelease/status (source: status/) — static status and incident pagestatic host
wwwrelease/www — redirect-only IIS siteseparate 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

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.

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

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

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:

HostIIS site rootCertificate
bentospaces.comrelease/htdocsapex (+ www)
www.bentospaces.comrelease/wwwthe same certificate, separate redirect site
api.bentospaces.comrelease/apiAPI host
developer.bentospaces.comrelease/developerStudio host
manage.bentospaces.comrelease/manageoperator host
marketplace.bentospaces.comrelease/marketplacecatalog host
status.bentospaces.comrelease/statusstatus host
staging.bentospaces.comstaging UI onlystaging 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.

Marketplace

marketplace/ is a self-contained static site:

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:

SurfaceLocalProduction
webtophttp://localhost:5080https://bentospaces.com/
apihttp://localhost:5081https://api.bentospaces.com/
studiohttp://localhost:5082https://developer.bentospaces.com/
marketplacehttp://localhost:5083https://marketplace.bentospaces.com/
managehttp://localhost:5084https://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:

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

  1. Back up live data
   BENTO_STORAGE_ROOT=/srv/bento-data ./scripts/backup-data.sh
  1. 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.

  1. Set production configuration
    • Storage__Root outside release/
    • Hosts__ServeShell=false and the four origin allowlist entries
    • Marketplace__Url=https://api.bentospaces.com/api/market/registry.json
    • Marketplace__StaticBase=https://marketplace.bentospaces.com/
    • Manage__Operators (operator usernames), Manage__Token (automation) and Auth__CookieDomain
  2. Point the data root at the backup (or restore):
  3. BENTO_STORAGE_ROOT=/srv/bento-data ./scripts/restore-data.sh <archive> --yes
  4. Restart the API, then run the smoke tests:
   node scripts/five-smoke.mjs        # local five-host
   node scripts/split-smoke.mjs       # shell + API boundary
  1. Check the live surfaces — webtop, API health, Studio, marketplace registry, manage.
  2. Rollback by stopping the API, restoring the latest data archive, and swapping the static
  3. 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.