Server: chatcopsNext(), one catch-all route for Next.js
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
F-12 task 5. In Next.js the chat needs two route files today: app/api/chat/route.ts and app/api/chat/session/route.ts, which re-exports the first (website/src/content/docs/server/fetch-runtimes.mdx:13-40). Forgetting the second breaks session tokens. A Next adapter can serve every sub-path from one catch-all route:
// app/api/chat/[[...path]]/route.ts
import { chatcopsNext } from '@chatcops/server/next';
export const { POST, OPTIONS } = chatcopsNext({
provider: { type: 'claude', apiKey: process.env.ANTHROPIC_API_KEY! },
systemPrompt: 'You are a helpful assistant.',
sessionSecrets: [process.env.CHATCOPS_SESSION_SECRET!],
});
export const runtime = 'nodejs';
What to do
- A new
packages/server/src/adapters/next.tswithchatcopsNext(config), returning{ POST, OPTIONS }, both(request: Request) => Promise<Response>. Build it likechatcopsVercelHandler(packages/server/src/adapters/vercel.ts): onecreateChatHandlerat module scope, andfetchChatResponsewith the client IP.fetchChatResponsealready sends a path ending in/sessionto the session endpoint (isSessionPathinpackages/server/src/http.ts), so the catch-all works without routing of its own. Add aGETlater, with handoff (F-10). - Add
"./next"to theexportsinpackages/server/package.json, next to./vercel. - Docs: change the Next.js section of
fetch-runtimes.mdxto the single catch-all route, and keep the two-file version as a short note for older code.
Acceptance criteria
- Unit tests with real
Requestobjects: a chat POST to/api/chat, a session POST to/api/chat/session, anOPTIONSpreflight, and a request without a token getting 401 - You tried it in a fresh Next.js app (
npx create-next-app@latest), following the updated docs, and the widget chats with it. Say what you ran in the PR. -
pnpm docs:checkpasses (it checks that the server example setssessionSecrets) - A minor changeset for
@chatcops/server;pnpm test:coverage,pnpm lint,pnpm publintandpnpm api(commit the snapshot) pass
Comment on this issue to be assigned.
- 主要語言
- TypeScript
- 星號
- 13
- 分支
- 7
- 平均合併
- 3 小時 14 分鐘
- 30 天內合併 PR
- 332
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
codercops/chatcops 的其他 Issue
-
Ingest: a crawl source for sites without a sitemap可能已有人在做 @bhushan4work 於 4 天前認領。 未關閉enhancement
codercops/chatcops#586 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Widget: a code block tagged `c++`, `c#` or `objective-c` shows part of the tag as code可能已有人在做 @prakashNalla 於 6 天前認領。 未關閉bug widget
codercops/chatcops#578 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Docs: Astro, Nuxt and SvelteKit guides for the server可能已有人在做 @anurag2787 於 6 天前認領。 未關閉documentation
codercops/chatcops#575 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
@chatcops/react: a <ChatCops> component and useChatCops() hook可能已有人在做 @Saifjafri212213 於 6 天前認領。 未關閉enhancement widget
codercops/chatcops#573 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 25/100
codercops/chatcops#546 · 6 則留言 ·
維護者通常 1 天內回覆
查看 codercops/chatcops 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/vscode-containers#655 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 則留言 ·
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish step可能已有人在做 @albertteoh 今天認領。 未關閉documentation
難度 2/5 1-3 小時 新手友好度 85/100
jaegertracing/jaeger-ui#4739 ·
維護者通常 1 天內回覆
-
check:passed streams:add
難度 2/5 1-3 小時 新手友好度 64/100
維護者通常 1 天內回覆