Skip to content

Commit fbb8137

Browse files
committed
feat(studio): enhance createStudioStaticPlugin to support dev mode redirection
1 parent 190ace8 commit fbb8137

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

packages/cli/src/commands/serve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export const serveCommand = new Command('serve')
255255
console.warn(chalk.yellow(` ⚠ @objectstack/studio not found — skipping UI`));
256256
} else if (hasStudioDist(studioPath)) {
257257
const distPath = path.join(studioPath, 'dist');
258-
await kernel.use(createStudioStaticPlugin(distPath));
258+
await kernel.use(createStudioStaticPlugin(distPath, { isDev }));
259259
trackPlugin('StudioUI');
260260
} else {
261261
console.warn(chalk.yellow(` ⚠ Studio dist not found — run "pnpm --filter @objectstack/studio build" first`));

packages/cli/src/utils/studio.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export function createStudioProxyPlugin(vitePort: number) {
240240
* Uses Node.js built-in fs for static file serving to avoid external
241241
* bundling dependencies.
242242
*/
243-
export function createStudioStaticPlugin(distPath: string) {
243+
export function createStudioStaticPlugin(distPath: string, options?: { isDev?: boolean }) {
244244
return {
245245
name: 'com.objectstack.studio-static',
246246

@@ -271,8 +271,11 @@ export function createStudioStaticPlugin(distPath: string) {
271271
`$1="${STUDIO_PATH}/`,
272272
);
273273

274-
// Redirect root and bare path to Studio
275-
app.get('/', (c: any) => c.redirect(`${STUDIO_PATH}/`));
274+
// In dev mode, redirect root to Studio for convenience
275+
if (options?.isDev) {
276+
app.get('/', (c: any) => c.redirect(`${STUDIO_PATH}/`));
277+
}
278+
// Redirect bare path
276279
app.get(STUDIO_PATH, (c: any) => c.redirect(`${STUDIO_PATH}/`));
277280

278281
// Serve static files with SPA fallback

0 commit comments

Comments
 (0)