Skip to content

fix(devframe): forward allowedOrigins through createDevServer - #230

Open
dvcolomban wants to merge 1 commit into
devframes:mainfrom
dvcolomban:fix/dev-server-allowed-origins
Open

fix(devframe): forward allowedOrigins through createDevServer#230
dvcolomban wants to merge 1 commit into
devframes:mainfrom
dvcolomban:fix/dev-server-allowed-origins

Conversation

@dvcolomban

@dvcolomban dvcolomban commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What

Not a new capability — initDevframe/initiate.ts (packages/devframe/src/adapters/initiate.ts) already accepts and fully plumbs allowedOrigins?: readonly string[] | WsOriginRegistry | false down to the WS transport's origin check (ws-server.ts), which already implements the full WsOriginRegistry check. createDevServer (packages/devframe/src/adapters/dev.ts) is a thinner adapter built on top of initDevframe, and it simply never declared or forwarded this already-existing option into its initDevframe(...) call. Passing allowedOrigins to createDevServer today either throws a type error or is a silent no-op depending on how loosely the call site is typed — createDevServer was the one seam in the chain dropping it.

This adds allowedOrigins to CreateDevServerOptions (documented the same way as initiate.ts's own field, including the WsOriginRegistry escape hatch and the false "disables the check entirely, not recommended" caveat) and forwards options.allowedOrigins into the initDevframe({...}) call — pure plumbing, no new runtime behavior.

Why this matters

createDevServer is the adapter most CLI/dev-server consumers reach for directly. Anyone reaching the tool from another host (LAN, tunnel) or wiring a WsOriginRegistry for external viewer registration currently has no first-party way to configure that through createDevServer — only through the lower-level initDevframe, which most consumers don't call directly.

Tests

Three new cases in packages/devframe/src/adapters/__tests__/dev.test.ts:

  • default behavior stays loopback-only when allowedOrigins is omitted
  • an array of extra origins is honored on top of the loopback default (and a still-disallowed origin is still rejected)
  • a WsOriginRegistry object gates the upgrade end to end — connecting before registration is rejected, then registering the viewer origin through the registry lets the same connection through

All assert via a real WS connect/close outcome, not by inspecting isAllowed call counts, matching the existing origin-check tests in ws.test.ts.

pnpm lint && pnpm knip && pnpm test && pnpm typecheck && pnpm build all pass.

CreateDevServerOptions had no allowedOrigins field, and createDevServer
never forwarded one into its initDevframe(...) call, even though the
lower-level initDevframe/initiate.ts already accepts allowedOrigins and
the WS transport underneath already implements the full
WsOriginRegistry check. Passing allowedOrigins to createDevServer was
either a type error or a silent no-op depending on the call site.

Adds the field to CreateDevServerOptions (documented the same way as
initiate.ts's own field) and forwards it into the initDevframe call.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Copilot AI lite review requested due to automatic review settings August 14, 2026 14:20
@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit bc5b877
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7f244bce1a7d00086baae7
😎 Deploy Preview https://deploy-preview-230--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an options “drop” in the devframe dev-server adapter by adding allowedOrigins to CreateDevServerOptions and forwarding it into the underlying initDevframe(...) call, enabling consumers to configure the existing WS origin gate through the primary createDevServer API.

Changes:

  • Extend CreateDevServerOptions with allowedOrigins?: readonly string[] | WsOriginRegistry | false and document its behavior.
  • Forward options.allowedOrigins through createDevServer into initDevframe.
  • Add end-to-end adapter tests covering default, array allowlist, and WsOriginRegistry-gated origin behavior; update the public API snapshot accordingly.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
tests/snapshots/tsnapi/devframe/adapters/dev.snapshot.d.ts Updates the public API snapshot to include allowedOrigins on CreateDevServerOptions.
packages/devframe/src/adapters/dev.ts Adds the allowedOrigins option to the dev-server adapter options and forwards it into initDevframe.
packages/devframe/src/adapters/tests/dev.test.ts Adds integration tests validating origin checks for default behavior, explicit allowlists, and WsOriginRegistry registration flow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants