You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
4.1 KiB
76 lines
4.1 KiB
export type RouteRule = {
|
|
path: string;
|
|
methods?: string[];
|
|
};
|
|
|
|
export const API_ALLOWLIST: RouteRule[] = [
|
|
{ path: "/api/auth/captcha", methods: ["GET"] },
|
|
{ path: "/api/auth/login", methods: ["POST"] },
|
|
{ path: "/api/auth/register", methods: ["POST"] },
|
|
/** 访客可读:无 Cookie 时不查库,用于客户端与 SSR 会话对齐 */
|
|
{ path: "/api/auth/session", methods: ["GET"] },
|
|
{ path: "/api/config/global", methods: ["GET"] },
|
|
{ path: "/api/auth/oauth/:provider/callback", methods: ["GET"] },
|
|
{ path: "/api/auth/oauth/:provider/authorize", methods: ["GET"] },
|
|
/** 客户端错误上报 — 公开(无需登录) */
|
|
{ path: "/api/_error-report", methods: ["POST"] },
|
|
/** 卡片列表 + 详情 */
|
|
{ path: "/api/cards", methods: ["GET"] },
|
|
{ path: "/api/cards/:id", methods: ["GET"] },
|
|
/** 分类(只读) */
|
|
{ path: "/api/categories", methods: ["GET"] },
|
|
{ path: "/api/categories/:id", methods: ["GET"] },
|
|
/** 标签(只读) */
|
|
{ path: "/api/tags", methods: ["GET"] },
|
|
{ path: "/api/tags/:id", methods: ["GET"] },
|
|
/** 文章列表 + 详情 */
|
|
{ path: "/api/articles", methods: ["GET"] },
|
|
{ path: "/api/articles/:id", methods: ["GET"] },
|
|
/** 工具(只读) */
|
|
{ path: "/api/tools", methods: ["GET"] },
|
|
{ path: "/api/tools/:id", methods: ["GET"] },
|
|
{ path: "/api/pic/random", methods: ["GET"] },
|
|
/** 聊天消息只读 — 公开 */
|
|
{ path: "/api/chat/messages", methods: ["GET"] },
|
|
/** 想法 — 公开读写(匿名发布) */
|
|
{ path: "/api/ideas", methods: ["GET", "POST"] },
|
|
/** 项目 — 公开只读,登录后增删改 */
|
|
{ path: "/api/projects", methods: ["GET"] },
|
|
{ path: "/api/projects/:id", methods: ["GET", "PUT", "DELETE"] },
|
|
/** Agent — 未登录用户通过 tempToken 使用 */
|
|
{ path: "/api/agents/default-agent", methods: ["GET"] },
|
|
{ path: "/api/agents/:agentSlug/models", methods: ["GET"] },
|
|
{ path: "/api/agents/:agentSlug/info", methods: ["GET"] },
|
|
{ path: "/api/agents/:agentSlug/sessions", methods: ["GET", "POST"] },
|
|
{ path: "/api/agents/:agentSlug/sessions/:id", methods: ["GET", "PUT", "DELETE"] },
|
|
{ path: "/api/agents/:agentSlug/sessions/:id/config", methods: ["PUT"] },
|
|
{ path: "/api/agents/:agentSlug/sessions/:id/messages", methods: ["GET"] },
|
|
{ path: "/api/agents/:agentSlug/chat", methods: ["POST"] },
|
|
{ path: "/api/agents/:agentSlug/chat/stream", methods: ["GET"] },
|
|
{ path: "/api/agents/:agentSlug/chat/stop", methods: ["POST"] },
|
|
{ path: "/api/agents/:agentSlug/chat/tool-approve", methods: ["POST"] },
|
|
{ path: "/api/agents/:agentSlug/chat/cleanup-approvals", methods: ["POST"] },
|
|
{ path: "/api/agents/:agentSlug/feedback", methods: ["POST"] },
|
|
{ path: "/api/agents/:agentSlug/migrate", methods: ["POST"] },
|
|
/** A2A 协议 — Agent Card 公开(规范要求),JSON-RPC 端点走身份解析 */
|
|
{ path: "/api/agents/:agentSlug/agent-card", methods: ["GET"] },
|
|
{ path: "/api/agents/:agentSlug/a2a", methods: ["POST"] },
|
|
{ path: "/api/agent-tools", methods: ["GET"] },
|
|
{ path: "/api/llm/chat/tools", methods: ["GET"] },
|
|
/** 角色卡(Character)— 未登录用户通过 tempToken 使用 */
|
|
{ path: "/api/characters", methods: ["GET"] },
|
|
{ path: "/api/characters/:slug", methods: ["GET"] },
|
|
{ path: "/api/characters/:slug/info", methods: ["GET"] },
|
|
{ path: "/api/characters/:slug/models", methods: ["GET"] },
|
|
{ path: "/api/characters/:slug/sessions", methods: ["GET", "POST"] },
|
|
{ path: "/api/characters/:slug/sessions/:id", methods: ["GET", "PUT", "DELETE"] },
|
|
{ path: "/api/characters/:slug/sessions/:id/config", methods: ["PUT"] },
|
|
{ path: "/api/characters/:slug/sessions/:id/messages", methods: ["GET"] },
|
|
{ path: "/api/characters/:slug/chat", methods: ["POST"] },
|
|
{ path: "/api/characters/:slug/chat/stop", methods: ["POST"] },
|
|
];
|
|
|
|
export const FRONTEND_LOGIN_PATH = "/auth/login"
|
|
export const FRONTEND_REGISTER_PATH = "/auth/register"
|
|
export const FRONTEND_PAGE_ALLOWLIST = new Set(["/", FRONTEND_LOGIN_PATH, FRONTEND_REGISTER_PATH, '/test', '/articles', '/projects', '/chat/:agentSlug', '/characters', '/characters/:slug'])
|
|
export const FRONTEND_PAGE_GUEST_ONLY = new Set([FRONTEND_LOGIN_PATH, FRONTEND_REGISTER_PATH])
|
|
|