Skip to content

feat(hub): serve static builds from a deploy base - #494

Open
0froq wants to merge 1 commit into
devframes:mainfrom
0froq:fix/hub-deploy-base
Open

0froq wants to merge 1 commit into
devframes:mainfrom
0froq:fix/hub-deploy-base

Conversation

@0froq

@0froq 0froq commented Nov 15, 2026

Copy link
Copy Markdown

Fixes #493

Description

buildHub now takes deployBase, the URL prefix the deploy root is served under. Every root-absolute URL the build emits is rebased under it, covering frame bases in __index.json, dock urls and icons plus page-script imports in the baked RPC dump, ctx.staticConfig URLs in the connection metas, and absolute references inside each copied SPA's text assets. A base outside deployBase throws DF8007.

The output keeps the deploy-root layout from #355, with the prefix applied to URLs.

Test

  • New test rebases the deploy-root layout under deployBase installs a frame at /__alpha/ and a static mount with an iframe dock at /__panel/, builds with base: '/ci-build-123456/__devtools/' and deployBase: '/ci-build-123456/', then checks the index, the per-frame meta, the dock snapshot, and the rewritten SPA files.
  • End to end with the vitejs/devtools reproduction from #583 on 0.8.2: passed the new option through buildStaticDevTools, rebuilt with vite build --base /ci-build-123456/, and served custom-dir at that path. The viewer, the rolldown panel, the messages and inspect panels, the _nuxt chunks, the assets, and the renderer all return 200. A scan of every baked absolute URL (26 unique) returned 200, and no root-absolute "/__..." reference remained.

Context

Downstream report: vitejs/devtools#583. Closing it needs a Vite-side follow-up that passes deployBase through buildStaticDevTools, plus a hub release.

The Vite integrations ship prebuilt Nuxt SPAs with /__devtools-rolldown/... baked into their HTML. The copy step rewrites their text assets to the served prefix.

buildHub bakes root-absolute URLs for frame bases, dock entries, page
scripts, and per-SPA asset references. A deploy base prefixes them so the
same output serves under a subpath, while the on-disk deploy-root layout
stays unchanged.
@vercel

vercel Bot commented Nov 15, 2026

Copy link
Copy Markdown

@0froq is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/494?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-11-15 16:19 UTC
🔗 head 6daee1a
🤖 automated by pulls.review

{
  "headSha": "6daee1acdd88f486e84b801512a8186021ed4e9c",
  "result": {
    "overallSummary": "buildHub gains a deployBase option so static builds can be served from a URL prefix other than the domain root: every root-absolute URL it bakes (frame bases, dock metadata, the RPC dump, static config, and copied SPA assets) is rewritten under that prefix, with a new DF8007 diagnostic guarding against an inconsistent base.",
    "groups": [
      {
        "key": "deploy-base-core",
        "label": "Deploy base rebasing",
        "summary": "Adds a deployBase option to buildHub that rebases every root-absolute URL the build emits (frame bases, dock urls/icons, baked RPC dump page-script imports, ctx.staticConfig entries, and text assets copied from static mounts) under a served deploy prefix, and rejects a base outside deployBase with a new DF8007 diagnostic.",
        "category": "core",
        "filePaths": [
          "packages/hub/src/node/build.ts",
          "packages/hub/src/node/diagnostics.ts"
        ],
        "critical": true,
        "lineNotes": [
          {
            "path": "packages/hub/src/node/build.ts",
            "side": "additions",
            "line": 171,
            "text": "String replaceAll with a manual already-prefixed check implements the text rewrite; worth double-checking for false-positive matches inside larger tokens.",
            "critical": true
          }
        ]
      },
      {
        "key": "tests",
        "label": "Tests",
        "summary": "Adds coverage for the DF8007 rejection and for the full deploy-root layout being rebased under deployBase, plus the updated public-API type snapshot reflecting the new option.",
        "category": "tests",
        "filePaths": [
          "packages/hub/src/node/__tests__/build.test.ts",
          "tests/__snapshots__/tsnapi/@devframes/hub/build.snapshot.d.ts"
        ]
      },
      {
        "key": "docs",
        "label": "Documentation",
        "summary": "Documents the new DF8007 error and the deployBase build option.",
        "category": "docs",
        "filePaths": [
          "docs/content/6.errors/DF8007.md",
          "docs/content/8.references/6.hub-api.md"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-11-15T16:19:20.046Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

@0froq

0froq commented Nov 15, 2026

Copy link
Copy Markdown
Author

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/494?from=0froq

raw result

💭 analyzed by openai-compatible/opencode-go/deepseek-v4.1-flash
🕰️ 2026-11-15 16:20 UTC
🔗 head 6daee1a
🤖 automated by pulls.review

{
  "headSha": "6daee1acdd88f486e84b801512a8186021ed4e9c",
  "result": {
    "overallSummary": "`buildHub` gains a `deployBase` option: the deploy root keeps its on-disk layout from #355, but every root-absolute URL the build emits (frame bases, dock urls/icons, `ctx.staticConfig`, page-script imports) is rebased under the served prefix so the output works below the domain root. This unblocks the Vite DevTools downstream case (vitejs/devtools#583), which serves prebuilt Nuxt SPAs from a CI build path. A `base` outside `deployBase` is rejected with the new `DF8007`.",
    "groups": [
      {
        "key": "deploy-base-rebasing",
        "label": "Deploy base rebasing",
        "summary": "Implements the option itself in `buildHub`: resolve the deploy prefix, strip it when mapping a served URL back to its on-disk location, and rebase the URLs the build bakes (index/frame metas, RPC dump payloads, client-imports module, copied SPA text assets). Adds `DF8007` for a hub base that is not under the deploy base.",
        "category": "core",
        "filePaths": [
          "packages/hub/src/node/build.ts",
          "packages/hub/src/node/diagnostics.ts"
        ],
        "critical": true,
        "lineNotes": [
          {
            "path": "packages/hub/src/node/build.ts",
            "side": "additions",
            "line": 168,
            "text": "The rewrite table is built only from frame bases and static-dir base urls. A dock url/icon pointing at a path that is not a registered mount keeps its root-absolute form after rebasing."
          },
          {
            "path": "packages/hub/src/node/build.ts",
            "side": "additions",
            "line": 249,
            "text": "`alreadyPrefixed` looks back `prefixedBefore.length` chars in the whole text, so an occurrence already preceded by the deploy prefix is skipped (idempotency). Any unrelated text that happens to end with the prefix at that offset would also be left unrebased."
          },
          {
            "path": "packages/hub/src/node/build.ts",
            "side": "additions",
            "line": 278,
            "text": "Non-plain objects (Date, Map, class instances) are returned untouched, so a URL stored inside one is not rebased."
          },
          {
            "path": "packages/hub/src/node/build.ts",
            "side": "additions",
            "line": 296,
            "text": "Only `.css/.html/.js/.json/.mjs/.svg` are rewritten. Root-absolute references in any other copied file (e.g. `.webmanifest`, `.txt`, `.map`, extensionless) stay un-prefixed."
          }
        ]
      },
      {
        "key": "tests",
        "label": "Tests and API snapshot",
        "summary": "Covers both new paths: the `DF8007` rejection and a full build that installs a frame plus a static mount with an iframe dock under a CI prefix, then asserts the on-disk layout is unchanged while index, frame meta, dock snapshot and rewritten SPA files carry the served URLs. The `.d.ts` snapshot records the new public option.",
        "category": "tests",
        "filePaths": [
          "packages/hub/src/node/__tests__/build.test.ts",
          "tests/__snapshots__/tsnapi/@devframes/hub/build.snapshot.d.ts"
        ],
        "fileNotes": [
          {
            "path": "tests/__snapshots__/tsnapi/@devframes/hub/build.snapshot.d.ts",
            "text": "Generated by the tsnapi snapshot task; regenerate it rather than editing by hand."
          }
        ]
      },
      {
        "key": "docs",
        "label": "Docs",
        "summary": "Documents the new option in the `buildHub()` reference and adds the `DF8007` error page with the expected good/bad examples.",
        "category": "docs",
        "filePaths": [
          "docs/content/6.errors/DF8007.md",
          "docs/content/8.references/6.hub-api.md"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-11-15T16:20:14.900Z",
    "model": "openai-compatible/opencode-go/deepseek-v4.1-flash",
    "locale": "en"
  }
}

This branch has not been deployed

No deployments
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.

[Bug report] Static builds can't be served under a subpath: baked URLs stay root-absolute

1 participant