画布模板管理页 `/canvas/template-admin` 返回404 JSON而不是页面
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 缺陷描述
**路径**:`/canvas/template-admin`(前端 WEB 服务,端口 25022)
**现象**:访问该路径返回 HTTP 404,Content-Type 为 `application/json`,响应体为:
```json
{"error":"not_found","traceId":"..."}
```
**期望**:返回画布模板管理的 React 页面(HTTP 200,Content-Type text/html)。
## 复现步骤
```bash
curl -I http://localhost:25022/canvas/template-admin
# 返回: HTTP/1.1 404 Not Found, Content-Type: application/json
```
## 根因分析
**`apps/web/next.config.mjs` 第 187 行**有一条通配符 rewrite 规则:
```js
{ source: `${prefix}/canvas/:path*`, destination: `${apiOrigin}/canvas/:path*` },
```
该规则将所有 `/canvas/*` 路径代理到 API 后端,包括原本应由 Next.js `[screen]/page.tsx` 路由处理的前端页面路径 `/canvas/template-admin`。
API 后端没有这个路径,因此返回 JSON 404。
**对比同类已知问题**:`/canvas/templates` 在第 186 行有显式 rewrite 规则(API 路由),因此其 API 操作正常。但 `/canvas/template-admin` 是前端管理页面,**不应被代理到 API**,而应该由 Next.js 的 `app/canvas/[screen]/page.tsx` 的动态路由处理。
组件文件已存在:`apps/web/components/canvas/template-admin.tsx`。
## 修复方向
在通配符规则 `/canvas/:path*` **之前**添加豁免,让 `/canvas/template-admin` 不被代理:
```js
// 前端管理页,不代理到API - 应由 Next.js [screen] 动态路由处理
// (不加这条的话 /canvas/:path* 会把它代理到 API 返回 JSON 404)
{ source: `${prefix}/canvas/template-admin`, destination: `/canvas/template-admin` },
```
或者修改通配符规则为排除已知前端路径的形式。
## 实测证据
- 实测 SHA:`622dfd2ee8568300ee87755d8b1065c946788749`
- WEB 端口:25022
- `curl -s http://127.0.0.1:25022/canvas/template-admin` → `{"error":"not_found",...}`
- `curl -s -I http://127.0.0.1:25022/canvas/template-admin` → `HTTP/1.1 404 Not Found, Content-Type: application/json`
## 关联
- 发现于 #3413 重测线 T21
- 同类已修复问题:/capabilities、/canvas/templates、/skills、/agent-runs 等路径(见 next.config.mjs 注释"第六次踩坑")
Contributor guide
No contributing guide indexed for this repository
Research direction
Inspect apps/web/next.config.mjs around the explicit /canvas/templates and wildcard /canvas/:path* rewrites, then check app/canvas/[screen]/page.tsx and components/canvas/template-admin.tsx. Add the documented exception or adjust the wildcard, and verify with curl that /canvas/template-admin returns HTTP 200 with text/html rather than the API's JSON 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100