Skip to main content

Change a Web App Setting or Release a Flag

The web app's settings are the runtimeEnvironment values in qubital-infra's staging/webapp.json and production/webapp.json: a pull request there changes them, with no new build. A release flag lives in the app's code instead, and reaches prod with a release. How both work is in Web and Desktop Release.

Change a runtime value​

The image reads seven keys: API_URL, LIVEKIT_URL, REALTIME_ORIGIN, AVATARS_ORIGIN, STORAGE_ORIGINS, SENTRY_DSN and ENVIRONMENT. All of them are public, so they live in the file; the web app has no secrets.

  1. Staging first. In qubital-infra, open a pull request that changes the value in staging/webapp.json, in the webapp node's spec.runtimeEnvironment. For example, to serve staging's avatars from another host:

    "runtimeEnvironment": {
    - "AVATARS_ORIGIN": "https://avatars.qubital-test.com",
    + "AVATARS_ORIGIN": "https://avatars-eu.qubital-test.com",
  2. Merge it after review. Merging deploys: Northflank restarts staging's web app with the new value, and verify checks it. The container checks the value as it starts. A malformed one stops it before it serves, so the deploy never becomes ready and the running version keeps serving; the container's log names the key, as in 05-qubital-config.envsh: AVATARS_ORIGIN is not an https origin, so the web app cannot start.

  3. Check staging in a signed-in browser: https://app.qubital-test.com/config.js holds API_URL, LIVEKIT_URL, SENTRY_DSN and ENVIRONMENT. The other three show up in the page's Content-Security-Policy response header.

  4. Then production: a second pull request that makes the matching change, with prod's value, in production/webapp.json. Once it is merged, check it:

    curl -fsS https://app.qubital.space/config.js
    curl -fsSI https://app.qubital.space/ | grep -i '^content-security-policy'

The rules qubital-infra checks on every pull request:

  • Both files declare the same keys (rule 8). A value can change in one file at a time, but adding or removing a key changes both files in one pull request. A new key also needs the image to read it: a change to apps/web/nginx/05-qubital-config.envsh and the app in qubital-apps first.
  • LIVEKIT_URL equals the api node's in the same folder's backend.json (rule 11), so the web app joins the LiveKit project its backend issues tokens for. Change both in one pull request.

When each app gets the new value:

  • The web app: at once. Once the restart finishes, every page load gets it: /config.js is never cached.
  • The desktop app: only at its next release. It has API_URL, LIVEKIT_URL, REALTIME_ORIGIN, AVATARS_ORIGIN and STORAGE_ORIGINS built in, read from production/webapp.json when the release's candidate is built. Until then, installed apps keep their old values. SENTRY_DSN and ENVIRONMENT are the web app's alone: the desktop app has its own Sentry project, and always runs as production.

Change prod's values between releases. A change to one of those five values in production/webapp.json while a candidate waits makes its publish refuse, because the desktop app would disagree with the web app; build a new candidate then. A change in the middle of a publish, after its web deploy, leaves it unable to finish (Release the Web and Desktop Apps).

Release a flag​

A release flag holds a staging value and a production value, in RELEASE_FLAGS in packages/app-shared/src/config/releaseFlags.ts. The staging web app and local development read the staging value; the prod web app and every released desktop app read the production value.

  1. While the feature is built, it sits behind its flag: a qubital-apps pull request adds the flag, on for staging and off for production, and the code asks isReleased('newBilling'):

    const RELEASE_FLAGS = {
    newBilling: { staging: true, production: false }
    } satisfies Record<string, ReleaseFlagValues>;

    Staging has the feature once that merge deploys; prod doesn't.

  2. To release it, a qubital-apps pull request sets its production value to true:

    newBilling: { staging: true, production: true }

    Merge it. Staging already has the flag on, so nothing changes there.

  3. The next release turns it on in prod: the web app at publish, and each desktop app as it installs that update (Release the Web and Desktop Apps).

  4. Once the feature has shipped and stays on, a pull request removes the flag and the code path it switched off.

Turning a feature off in prod works the same way: set its production value back to false, and release. In prod, a flag never changes without a release.