From d32c5aeff940d38529fff1af85bf1966c905e188 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 13 Jun 2026 09:04:56 +0000 Subject: [PATCH 1/2] Demo: make the homepage work on a multi-tenant server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The homepage demo used Zero() with no key, so on a multi-tenant server every data/file call 401s. Data failures were silent (lists just render empty) while the upload form surfaced the error — hence "upload is failing", though the whole demo was unauthenticated. - The demo now reads an optional project key from the URL (?key=pk_…) and passes it to the SDK, so an operator can point the showcase at a project. - On a multi-tenant server with no key it shows a clear notice (create a project in /admin, open as ?key=…) instead of failing silently. - loadEntries/loadFiles and the post/upload handlers now catch errors and show a friendly inline message rather than throwing uncaught. Server behavior is unchanged (authed upload already works — verified 201 with a project key). Added a test that / serves the demo and carries the key handling. 65/65 SQLite. --- public/index.html | 81 +++++++++++++++++++++++++++++++++-------------- test/api.test.ts | 10 ++++++ 2 files changed, 67 insertions(+), 24 deletions(-) diff --git a/public/index.html b/public/index.html index 80a76f3..0a9cfc7 100644 --- a/public/index.html +++ b/public/index.html @@ -59,6 +59,7 @@

This page is talking to its own backend

Everything below is served by the same instance, through /sdk.js. Open a second tab — new entries appear in both without a refresh (that's the realtime layer).

+

💬 Guestbook data + live sync

@@ -108,7 +109,16 @@

Everything a generated app needs

diff --git a/test/api.test.ts b/test/api.test.ts index 0bb1ede..d6812e1 100644 --- a/test/api.test.ts +++ b/test/api.test.ts @@ -90,8 +90,10 @@ test('serves the homepage demo, which is multi-tenant aware (accepts a ?key=)', assert.equal(res.status, 200); assert.match(res.headers.get('content-type') ?? '', /text\/html/); const html = await res.text(); - // The demo reads a project key from the URL so it works on a multi-tenant server. - assert.match(html, /\?key=|searchParams\.get\('key'\)/); + // The demo lets you paste a project key (kept in sessionStorage) so it works on + // a multi-tenant server, and shows a notice explaining how. + assert.match(html, /key-form/); + assert.match(html, /sessionStorage/); assert.match(html, /mt-notice/); });