serve
Serves a locally built custom front-end over HTTP while proxying API calls to a remote workspace. The fastest way to iterate on a custom UI without re-uploading after every change. For a workspace behind its own authentication layer, --browser-login signs in once and adds that session to every proxied call.
The folder being served must look like a compiled Mosaik.FrontEnd bundle — the CLI checks for a mosaik.app marker file in the root. With --watch the CLI compiles that folder for you.
Syntax
Usage: curiosity-cli serve --server <url> [--path <dir>] [--watch <project>] [--browser-login [--browser-login-header <name>]...] [--name <name>] [--port <port>] [options]
curiosity-cli serve \
--server https://my-workspace.example.com/ \
--path ./MyApp/bin/Debug/netstandard2.0/tps/
If neither --path nor --watch is given, the current working directory is used. With --watch, the CLI compiles the project itself and serves what the compiler produced, so --path is optional.
If --server is omitted, the CLI tries to guess the workspace URL by scanning the *.js files in the bundle for a serverURL / apiURL variable — don't rely on this in real workflows, pass --server explicitly.
Options
| Option | Description |
|---|---|
--server |
Workspace URL to proxy API calls to. Strongly recommended to set explicitly. Alias -s. Default: guessed from the bundle. |
--path |
Local path to the compiled tps/ folder. Alias -p. Default pwd, or the folder produced by --watch. |
--watch |
Path to a Transpose front-end project (a .csproj, or the folder holding one) to compile and keep watching. See Watch mode. Alias -w. |
--configuration |
Build configuration used by --watch. Default Debug. |
--browser-login |
Once the server is up, open a sign-in page in the default browser, and add the cookies and headers captured there to every request forwarded to the workspace. See Signing in through a browser. Default false. |
--browser-login-header |
With --browser-login, a request header to capture and inject besides Authorization. Repeat for several: --browser-login-header X-A --browser-login-header X-B. |
--name |
App name shown in the dev UI's nav bar. Default Mosaik. |
--ignore-certificate-errors |
Disable TLS validation against the proxied workspace. Dev only. Default false. |
--port |
Local TCP port to bind. Default 5000. |
--cert-file |
Path to a certificate to enable HTTPS on the local listener. |
--cert-password |
Password for the cert file, if encrypted. |
--listen-to-any |
Bind to 0.0.0.0 instead of localhost. Useful for testing from another device on the same network. Default false. |
--enable-cors |
Enable CORS on the local server. Default false. |
--path-base |
Mount the dev server under a base path (e.g. /myapp). |
How it works
Under the hood, serve:
- Starts a local Kestrel server pointing at your
tps/folder. - Patches the served
index.htmlso the browser loads your JS bundle, with the proxied server address, the loading splash, and cache-busting asset hashes injected. The folder is watched, so the injection is re-applied when its files change on disk. - Proxies all
/api/...calls to the configured--server— includingtext/event-streamresponses, which are streamed through rather than buffered, and WebSocket connections, which are relayed as a real HTTP upgrade in both directions. - With
--watch, also compiles the front-end project and reloads the browser after each rebuild. Without it,serveonly hosts what is already on disk — rebuild and refresh yourself. - With
--browser-login, adds the cookies and headers captured at sign-in to every proxied call.
For this to work, the remote workspace must allow CORS from the dev server's origin. Add http://localhost:5000 (or whatever port you used) to the MSK_CORS environment variable and restart the workspace process.
Watch mode (--watch)
serve normally hosts an already-compiled output folder. Pass --watch with a front-end project and it also compiles that project, serves what it produced, and keeps rebuilding as you edit:
curiosity-cli serve \
--server https://my-workspace.example.com/ \
--watch ./MyApp/MyApp.csproj
What this changes:
--pathbecomes optional. The compiled site is what gets served, so there is nothing to point at on a fresh checkout. Pass--pathanyway if you serve a folder assembled from more than just this project's output.- Referenced projects are watched too. The project's own sources and those of every project it references are watched, so editing a shared front-end library rebuilds the app. One save triggers one rebuild.
- The browser reloads itself. The served
index.htmlcarries an injected script that opens a WebSocket back to the dev server; after each successful rebuild the page reloads. A client that reconnects while behind the current build is caught up immediately instead of waiting for the next edit. - A CSS-only change skips the compiler. When a change is confined to stylesheets, the CSS is re-copied and swapped into the page without a reload, so the running app keeps whatever state it was in.
- A compile error leaves the previous build in place. The errors are printed in MSBuild's format; fix and save again. If the first build fails, or the project produces no site (no
tps.json),servereports it and exits with code1. - No
tpstool needed. The compiler runs in process, through theTranspose.Compiler.Librarypackage, so the standalone Transpose compiler does not have to be installed for this path. Builds are incremental — an edit confined to method bodies reuses the cached JavaScript of every type it didn't touch, and an untouched referenced project isn't recompiled at all.
Everything else about serve still applies while watching: API proxying, CORS, --path-base, and the HTTPS options.
--configuration selects the build configuration (Debug by default). Use --configuration Release to reproduce a release build's output locally.
Signing in through a browser (--browser-login)
A workspace behind its own authentication layer, such as an AWS load balancer with Amazon Cognito or an SSO gateway, rejects proxied API calls that do not carry that layer's session. --browser-login signs in once through a browser page and adds the session to every request serve forwards.
curiosity-cli serve \
--server https://my-workspace.example.com/ \
--path ./MyApp/bin/Debug/netstandard2.0/tps/ \
--browser-login \
--browser-login-header X-Custom-Auth
serve starts
The local server starts first. A port that is already taken, a certificate that does not load, or a failed first --watch build ends the command here, before any sign-in.
The sign-in page opens
The page opens in the default browser on Windows, macOS and Linux, at http://127.0.0.1:<port>/<random token>/. The address is also printed in the console, for an SSH session or a host with no desktop. The page shows the workspace as rendered by PocketCalculator, the headless browser engine that runs inside the CLI; your own browser only displays it and sends back clicks, typing, scrolling and paste. Sign in the way the workspace asks you to.
The session is captured
The sign-in is complete when the application has loaded for a signed-in user: the first successful GET /api/userdata, which needs both the authentication layer's cookies and the workspace's own sign-in. The CLI captures the session at that moment.
The tab opens your front-end
The same tab goes on to the front-end serve is hosting. When the workspace signed in with a bearer token, the address carries it as http://localhost:<port>/#/withtoken/<token>, the form the workspace's own SSO redirects use, so the front-end opens signed in. The token is in the URL fragment, which the browser never sends to a server.


What is captured
- Every cookie the sign-in browser holds,
HttpOnlycookies included. Each forwarded request gets the cookies that apply to the workspace URL, the same selection a browser makes. When the workspace or the layer in front of it sets a cookie on a proxied response (a refreshed load-balancer session, for example), the CLI keeps the new value. Authorization, plus each--browser-login-header, read from the/api/userdatarequest. They are added to forwarded requests and WebSocket connections that do not carry the header themselves. A header the CLI did not see on that request is reported in the console and not injected.- What the local browser sends wins. A cookie or header the served front-end sends itself replaces the captured one with the same name, so signing in to the served app with another account uses that account.
- Requests forwarded before the sign-in has finished go out with nothing added.
The captured session is held in memory for the life of the serve process. Nothing is written to disk; run the sign-in again after restarting serve.
The sign-in page
| Control | Effect |
|---|---|
| Red light | Cancels the sign-in. |
| Yellow light | Shrinks the frame to at most 1024 × 720 pixels. |
| Green light | Fills the browser tab. |
| Reload button, F5 | Reloads the workspace page. |
| Status chip | Shows Waiting for sign-in, Signed in or Cancelled. |
Cancelling, or pressing Ctrl+C in the console, before the application has loaded stops serve with exit code 1. Closing the tab does not cancel: open the address from the console again and the sign-in continues where it was.
Security
The page listens on 127.0.0.1 only, under a random path, and its WebSocket refuses connections from any other origin, so another page open in the same browser cannot drive or watch the sign-in.
Limitations
- Hover effects do not show: mouse movement is not forwarded, only clicks.
- On a high-density (HiDPI) display the page looks soft, because the frames are rendered at one device pixel per CSS pixel.
- A pop-up window that a sign-in page opens is not shown.
Typical workflow
See Custom Front-End development workflow for the full loop. The short version:
# Compile once, serve the output, rebuild and refresh by hand:
dotnet build
curiosity-cli serve -s http://localhost:8080 -p bin/Debug/netstandard2.0/tps
# Or let the CLI compile and rebuild for you:
curiosity-cli serve -s http://localhost:8080 -w .
# Iterate, then when ready:
curiosity-cli upload-front-end -s http://localhost:8080 -t $CURIOSITY_TOKEN -p bin/Debug/netstandard2.0/tps
Remarks
- Use
serveto iterate on a custom front-end locally while talking to a remote workspace, instead of re-uploading after each change. Add--watchto also compile the project and reload the page on every change. - Without
--watch, the target folder must already be a compiledMosaik.FrontEndbundle (it must contain amosaik.appmarker). Either way, the remote workspace must allow CORS from the dev server's origin. - Pass
--serverexplicitly; the URL-guessing fallback is for convenience only and shouldn't be relied on.--ignore-certificate-errorsis for local development only. - For a workspace behind its own authentication layer, add
--browser-loginto sign in once and have the session added to every proxied call.
See also
upload-front-end— push the bundle to the workspace when iteration is done.- Transpose Getting Started — the compiler that produces the
tps/folder. - Tesserae UI — the component library most custom front-ends are built on.
- Custom Front-End development workflow.