From eb41d7d52432009c103410e7a83fe9848241d2ba Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Sun, 25 Oct 2026 22:10:57 +0800 Subject: [PATCH] Check Studio health on an explicit API route --- apps/studio/src/pages/api/health.ts | 2 ++ apps/studio/src/pages/index.tsx | 2 +- docs/explore-stage-files.md | 4 ++++ scripts/deploy-studio.sh | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 apps/studio/src/pages/api/health.ts diff --git a/apps/studio/src/pages/api/health.ts b/apps/studio/src/pages/api/health.ts new file mode 100644 index 0000000..efeacca --- /dev/null +++ b/apps/studio/src/pages/api/health.ts @@ -0,0 +1,2 @@ +import type {NextApiRequest,NextApiResponse} from "next"; +export default function handler(req:NextApiRequest,res:NextApiResponse){res.setHeader("Cache-Control","no-store");if(!["GET","HEAD"].includes(req.method||""))return res.status(405).end();return req.method==="HEAD"?res.status(200).end():res.status(200).json({status:"ok",service:"prompt-studio"});} diff --git a/apps/studio/src/pages/index.tsx b/apps/studio/src/pages/index.tsx index 41d655e..ef4a17b 100644 --- a/apps/studio/src/pages/index.tsx +++ b/apps/studio/src/pages/index.tsx @@ -1,3 +1,3 @@ import Link from 'next/link'; import {ideas} from '../content/ideas'; -export default function Home(){return
YOUR CREATIVE WORKSPACE

今天,想表达什么?

一个页面,装下一个想法。让内容慢慢长成作品。

{ideas.map(i=>
{i.title}

{i.title}

{i.summary}

打开创作 →)}

新增作品:在 src/content/ideas.ts 添加内容,页面与导出会同步生成。

} +export default function Home(){return
YOUR CREATIVE WORKSPACE

今天,想表达什么?

一个页面,装下一个想法。让内容慢慢长成作品。

{ideas.map(i=>
{i.title}

{i.title}

{i.summary}

打开创作 →)}

新增作品:在 src/content/ideas.ts 添加内容,页面与导出会同步生成。

} diff --git a/docs/explore-stage-files.md b/docs/explore-stage-files.md index 8e12046..b5f4069 100644 --- a/docs/explore-stage-files.md +++ b/docs/explore-stage-files.md @@ -43,3 +43,7 @@ - `apps/wiki/src/pages/explore/`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。 - `apps/wiki/tests/explore.test.ts`:验证稳定 ID、纯文本响应、图片体积与缓存、旧文档引用及集成行为。 - `apps/wiki/tests/preview.test.ts`:验证稳定 ID、纯文本响应、图片体积与缓存、旧文档引用及集成行为。 + +- `apps/studio/src/pages/api/health.ts`:新增明确的健康检查接口,避免把 API 目录的 index 文件错误理解为 /api/index 路由。 +- `scripts/deploy-studio.sh`:健康检查修正为 `/studio/api/health`。 +- `apps/studio/src/pages/index.tsx`:AI 索引入口修正为实际 `/studio/api`。 diff --git a/scripts/deploy-studio.sh b/scripts/deploy-studio.sh index 35e2c88..02c0f50 100644 --- a/scripts/deploy-studio.sh +++ b/scripts/deploy-studio.sh @@ -18,7 +18,7 @@ rollback(){ if [ -n "$previous" ]; then write_compose "$previous"; docker compos trap rollback ERR docker compose -p prompt-studio -f /opt/prompt-studio/compose.yml up -d for attempt in {1..40}; do - if curl -fsS http://127.0.0.1:18134/studio/api/index >/dev/null; then printf '%s' "prompt-studio:$sha" > /opt/prompt-studio/image; exit 0; fi + if curl -fsS http://127.0.0.1:18134/studio/api/health >/dev/null; then printf '%s' "prompt-studio:$sha" > /opt/prompt-studio/image; exit 0; fi sleep 2 done false