mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
25715d4521
* feat(nitro): embed observability dashboard in-process at /_workflow Serve the @workflow/web observability UI inside the Nitro process at a configurable route (default /_workflow) instead of spawning a separate web server and 302-redirecting to it. Enabled in dev, omitted from production builds by default (so prod bundles carry no @workflow/web import). Never mounted on Vercel deploys (use the hosted dashboard). - @workflow/web: add a framework-neutral `@workflow/web/handler` (createWorkflowWebHandler) that serves SSR + static client assets + RPC as one Web Request->Response handler under a runtime basename (asset manifest URLs + publicPath are reprefixed so the dashboard is self-contained under its mount). Add `@workflow/web/registry` for embedded-dashboard discovery; make the RPC/stream client basename-aware. - @workflow/nitro: mount the handler in-process (Nitro v2 h3 + v3 native paths), gated by a new `dashboard` option (default = dev). - @workflow/cli: `workflow web` / `inspect --web` defer to a running embedded dashboard instead of starting a redundant server; pass `--standalone` to force the standalone UI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor(nitro): normalize dashboard path once, use isNitroV2() helper Address review feedback on the embedded dashboard: - Normalize the dashboard mount path in one place before it feeds both the Nitro route registration (`[path, path + '/**']`) and the handler `basename`. Force a single leading slash, strip trailing slashes, and reject the root mount, so a custom `path` can't make the route and the handler's internal `normalizeBasename` disagree. - Replace the handler-level `!nitro.routing` v2 checks with the existing `isNitroV2()` helper for consistent v2/v3 detection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Peter Wielander <mittgfu@gmail.com>
27 lines
940 B
TypeScript
27 lines
940 B
TypeScript
/**
|
|
* Base path the observability UI is mounted under.
|
|
*
|
|
* The standalone server mounts at the root (`""`), but when embedded in another
|
|
* server (e.g. `@workflow/nitro` at `/_workflow`) the API resource routes live
|
|
* under that prefix. The server threads the mount path through the React Router
|
|
* load context; `app/root.tsx` surfaces it to the browser via a global so that
|
|
* client-only `fetch` calls (RPC + stream reads) can target the right path
|
|
* regardless of the current route.
|
|
*/
|
|
|
|
declare global {
|
|
interface Window {
|
|
__WORKFLOW_BASENAME__?: string;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the mount-path prefix for client-side API fetches (e.g. `""` at the
|
|
* root, or `"/_workflow"` when embedded). Always client-only — server code
|
|
* reaches the world directly rather than via these HTTP routes.
|
|
*/
|
|
export function apiBase(): string {
|
|
if (typeof window === 'undefined') return '';
|
|
return window.__WORKFLOW_BASENAME__ ?? '';
|
|
}
|