Skip to content

feat: keep a built copy from reaching for a local Storybook - #3

Merged
hugobessa merged 1 commit into
mainfrom
feat/deployable-build
Oct 1, 2026
Merged

hugobessa merged 1 commit into
mainfrom
feat/deployable-build

Conversation

@hugobessa

Copy link
Copy Markdown
Contributor

What

  • isDevServer() in src/lib/runtime.ts: one place that says whether the viewer runs under prototype-lab dev or from a built copy (import.meta.env.DEV). canEditAnnotations() now uses it.
  • shouldReadStorybook() / isLocalUrl() in src/lib/storybook-links.ts, used by useStorybookLinks:
    • dev server: unchanged — reads Storybook unless storybook: false.
    • built copy: reads Storybook only when storybook.url (or --storybook) is set explicitly to a non-localhost address, e.g. a deployed Storybook. Otherwise status is disabled: no fetch, no notice.
  • README (Commands + Storybook links) and an Unreleased CHANGELOG entry.

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 fetched http://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 detection covers localhost, *.localhost, 127.x.x.x, [::1] and 0.0.0.0. Private LAN IPs count as reachable, on purpose.
  • The ?storybook= query override still applies once a deployed URL enables Storybook in a build.
  • Checked by hand: built the example with default Storybook options and served it statically. The page made no request beyond its own assets and showed no Storybook notice.
  • pnpm check, pnpm typecheck, pnpm test (379 tests) pass.

🤖 Generated with Claude Code

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>
@hugobessa
hugobessa merged commit ae44676 into main Oct 1, 2026
5 checks passed
@hugobessa
hugobessa deleted the feat/deployable-build branch October 1, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant