Turn a local app into a hosted one
The four things a local app needs before it can be hosted
For when the answer to “It runs on a server for other people, not just on my machine” is yes.
Derived from the Playground's own platform/ layer, which was built by taking a single-owner desktop tool toward hosted mode and finding the gaps the hard way.
Skip the rebuild
You do not write this one. It arrives in your project as ordinary source you can read, change and keep, with its audit record and its caveats beside it.
- Download the Playground. It is free and runs on your own machine.
- Start a new app and tick “It runs on a server for other people, not just on my machine”.
- This block is written in, along with anything else you ticked.
The mistake it removes
The dangerous half of going hosted is not the features you add: it is the assumptions a local app made that stop being true. A local tool can assume one user, one machine, a writable disk and a trusted caller. Hosting breaks all four at once, and the failures are silent: the app keeps serving, just wrongly.
What the audit found
Named rather than summarized. The reasoning behind each one ships inside the block, so it travels with the code instead of living on a page you have to trust. A finding marked fixed was fixed after the audit ran; the verdict above is still the one the audit gave.
- Manifest promises a session gate that the block does not ship major · Claims match behavior / Security Fixed after the audit in
f58080cf9 - Passcode validation is length only; whitespace and repeated characters pass minor · Security Fixed after the audit in
96112fef8 - Rules are not normalised the way targets are, so an abnormal deny rule silently never matches minor · Correctness Fixed after the audit in
c902471f0 - requestPath repairs an abnormal target to '/', contradicting the manifest's 'refusal, never a repair' minor · Claims match behavior Fixed after the audit in
b7579d68d - Readiness probe has no deadline; a hanging store leaves the probe pending forever minor · Error handling & resilience Fixed after the audit in
0ac85513a - Two exposure tests depend on the runner's environment minor · Verification integrity Fixed after the audit in
edea2cfea - Manifest says readiness() returns 503; the function returns a boolean and sets no status minor · Claims match behavior Fixed after the audit in
0ac85513a
One more finding is written in the auditors' internal shorthand, so it is not listed here. The full text is in the report inside the block. It was fixed after the audit, in 91940b48a.
What you still have to do
A copied file cannot own your secrets, your host or your legal obligations. This is the part the block deliberately does not claim.
- Mount the gate yourself, app.use(passcodeGate({ publicPaths: ['/health', '/ready'] })) before your routes, and serve the app over HTTPS so the Bearer passcode is not readable in transit. The gate, the passcode rules and the path checks ship and are tested (test/cloud-kit.test.mjs sections 4, 4b, 5, 6 and 7), but nothing is guarded until you mount it. One shared passcode is also not a user account: there is no per-user identity, no sign-in, no way to revoke one person short of changing AUTH_PASSCODE, and no limit on wrong guesses, so put a request limiter in front of the gate. Write deny rules in plain normalised form (/admin, not //admin or /admin/./), because rules are not normalised yet and an abnormal one never matches.
- Answer 503 yourself when readiness() returns ready:false, and give your orchestrator's readiness probe its own timeout. The function returns { ready, checks } and sets no status, so wiring it straight to res.json() answers 200 for a store that cannot write. Each store write is raced against a 2 s deadline, so a hanging store reports not ready instead of leaving the probe pending. What the tests do show is that an unreadable document throws rather than returning the fallback, and that an unwritable store reports not ready with the driver error in the log and not in the body.
- A real database at DATABASE_URL, with backups you have restored from at least once. The tests cover only the resolver that picks the backend and the rule that an unreadable document is never overwritten as empty. sql/cloud.sql is never applied by them, so the database side of the seam is ungraded, and the local-file backend lives on one disk with no copy anywhere else.
- The readiness probe deliberately keeps the failure REASON out of the response body. An orchestrator has no session, so that endpoint is public, and 'connect ECONNREFUSED 10.0.0.5:5432' would hand an unauthenticated caller your database's private address.
- This gets an app to SINGLE-tenant hosted. Serving several customers needs per-tenant isolation, which is enterprise-kit's territory and a bigger change than this block.
What lands in your project
node
- node/cloud-kit.js
storeSeam() (local file OR database behind one resolver), readiness() (returns ready:false on an unwritable or hanging store, each write raced against a 2 s deadline, reason in the LOG not the body; it sets no status, so your /ready handler must answer 503 on ready:false), requireExposureConfig() (refuse to boot half-configured; an unset HOST counts as exposed, never as loopback), normalizeRequestPath()/requestPath() (ONE normalization of the request target: protocol-relative '//', repeated and trailing slashes, '.' and '..', percent-encoding decoded before any decision, and a REFUSAL, never a repair, for anything still abnormal: normalizeRequestPath() answers ok:false and requestPath() answers null, never '/'), pathAllowed() (deny is read before allow, both against that same normalized value, and a path on neither list is denied), and passcodeGate()/checkPasscode() (the per-request check: every request must carry 'Authorization: Bearer <passcode>', compared in constant time; an unset or weak passcode (too short, whitespace at either end, one character or one piece repeated, fewer than 6 different characters) refuses every request with 503 rather than letting it through; publicPaths such as '/ready' are exact normalized paths). The gate does nothing until you mount it: app.use(passcodeGate({ publicPaths: ['/health', '/ready'] })) before your routes.
sql
- sql/cloud.sql
A minimal docs table for the database side of the seam. Same shape the local JSON store presents, so switching backends changes no calling code.
What you supply
- DATABASE_URL: set it and the seam resolves to the database; unset and it stays a local file
- HOST: the interface you pass to listen(). Only an explicit loopback value (127.0.0.1, localhost, ::1) counts as local. Unset or empty counts as EXPOSED, because listen() with no host binds every interface, so requireExposureConfig() refuses to boot without AUTH_REQUIRED=true. For local-only use set HOST=127.0.0.1 and listen on that same value
- AUTH_REQUIRED: true means requireExposureConfig() REFUSES to boot without a passcode set, and passcodeGate(), mounted in front of your routes, refuses any request that does not present that passcode. There is no login page or cookie session: the passcode travels as a Bearer header on every request
- AUTH_PASSCODE: checked by passcodeProblem() at boot and again by passcodeGate(), which refuses every request while it is unset or weak: shorter than the minimum length, whitespace at either end, one character or one piece repeated, or fewer than 6 different characters; a guessable passcode on a public port is the same as none
Licensed MIT. It is a starting point, not a finished product.
Get it
Download the Playground See the other blocks
Nothing here is locked. The files are yours, in your folder, under a permissive license.
Questions
- Is Turn a local app into a hosted one audited?
- It was audited on 2026-09-29, and the verdict was not a clean pass. 8 findings have been fixed since then, and the verdict stands until the block is audited again.
- What do I still have to do myself?
- Mount the gate yourself, app.use(passcodeGate({ publicPaths: ['/health', '/ready'] })) before your routes, and serve the app over HTTPS so the Bearer passcode is not readable in transit. The gate, the passcode rules and the path checks ship and are tested (test/cloud-kit.test.mjs sections 4, 4b, 5, 6 and 7), but nothing is guarded until you mount it. One shared passcode is also not a user account: there is no per-user identity, no sign-in, no way to revoke one person short of changing AUTH_PASSCODE, and no limit on wrong guesses, so put a request limiter in front of the gate. Write deny rules in plain normalised form (/admin, not //admin or /admin/./), because rules are not normalised yet and an abnormal one never matches.
- How do I get this code?
- Download the Playground, start a new app, and tick “It runs on a server for other people, not just on my machine”. The block is written into your project as ordinary source you can read and edit.
All pre-built code blocks · Learn to build from zero · The coding guide