Repository navigation
feat: keep a built copy from reaching for a local Storybook - #3
Merged
Merged
Conversation
A copy from `prototype-lab build` is opened by people with no Storybook on their localhost. It used to fetch localhost:6006 anyway, showing a "Nothing is serving Storybook" note and, on a public page, risking a browser prompt for local network access. A build now links to Storybook only when the config names a deployed one; the dev server is unchanged. The dev-or-build check moves to `isDevServer()` in `src/lib/runtime.ts`, so comment editing and Storybook read the same flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
isDevServer()insrc/lib/runtime.ts: one place that says whether the viewer runs underprototype-lab devor from a built copy (import.meta.env.DEV).canEditAnnotations()now uses it.shouldReadStorybook()/isLocalUrl()insrc/lib/storybook-links.ts, used byuseStorybookLinks:storybook: false.storybook.url(or--storybook) is set explicitly to a non-localhost address, e.g. a deployed Storybook. Otherwise status isdisabled: no fetch, no notice.Why
We want to deploy built prototypes. Comments were already read-only in a build and the write endpoints are
apply: 'serve', but Storybook links weren't gated: every visitor's browser fetchedhttp://localhost:6006/index.json, got the "Nothing is serving Storybook" note, and on a public HTTPS page could trigger Chrome's local-network-access prompt.Reviewer notes
localhost,*.localhost,127.x.x.x,[::1]and0.0.0.0. Private LAN IPs count as reachable, on purpose.?storybook=query override still applies once a deployed URL enables Storybook in a build.pnpm check,pnpm typecheck,pnpm test(379 tests) pass.🤖 Generated with Claude Code