Demo: make the homepage upload (and data) work on a multi-tenant server#79
Merged
Conversation
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.
Per review: a key in the URL can leak into history/logs and is easy to forget. The demo now shows a "project key" box only on a multi-tenant server; the key is held in sessionStorage (this tab only, cleared when it closes) and never touches the URL. A "Clear" button forgets it. Entering or clearing the key reconnects the SDK and refreshes the lists + live subscription. Test asserts the key-form + sessionStorage handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the reported issue: the homepage upload form fails on a multi-tenant server.
Root cause
The homepage demo runs
Zero()with no key. In multi-tenant mode every data/file call requires a project key, so they all401—data list,files list, and upload. The data failures were silent (the lists just render empty), while the upload form has a visible action, so it looked like "upload is broken" when in fact the whole demo was unauthenticated. (Verified by reproduction: all three return401 "Provide a project key."; with a project key, upload returns201.)This is a demo/frontend gap, not a server bug — authed upload already works.
Fix (frontend only)
sessionStorage(this tab only, cleared when it closes) and never put in the URL — so it can't leak into history/logs or be shared by accident. A Clear button forgets it.loadEntries/loadFilesand the post/upload handlers now catch errors and show a friendly message instead of throwing uncaught.Verification
401s in multi-tenant; confirmed201upload once a project key is supplied./serves the demo HTML and carries the key-form +sessionStoragehandling + the notice. (No server logic changed.)https://claude.ai/code/session_018efxvWw3MRjdtvE5xgBqya
Generated by Claude Code