logo
0
0
WeChat Login
ForkfromBring/Tools/BaishanConsole, aheadmain1 commits

BaishanConsole

白山云 CDN OpenAPI 控制台 —— Next.js (App Router) + 通用代理。

架构

浏览器 (public/*.html + *.jsx 静态原型) │ fetch /api/bs/<path>?... ▼ Next.js 服务端 (app/api/bs/[...path]/route.ts) │ 注入 ?token=xxx, 透传 method / body / query / 限流响应头 ▼ https://cdn.api.baishancloud.com/<path>
  • 通用代理/api/bs/[...path] 一个 catch-all 路由覆盖所有 44 个白山云 OpenAPI。GET/POST/PUT/DELETE/PATCH 全部转发,原始 querystring 透传,token 自动注入。
  • Token 双源:服务端 BS_TOKEN 环境变量(推荐,浏览器拿不到)优先;缺失时前端从 localStorage 读取并通过 x-bs-token 请求头发给代理。
  • 限流头透传X-Ratelimit-* / X-Retry-After / Api-Id 原样回传。
  • 前端:原 HTML/JSX 设计稿放在 public/,由 Next.js 静态托管;/ 自动跳到 /BaishanConsole.html

快速开始

cp .env.example .env.local # 把 BS_TOKEN 填进去 npm install npm run dev # http://localhost:3000

构建 + 生产运行:

npm run build npm run start # 普通 Node server, 非 standalone

代理用法示例

# 用环境变量 token (服务端注入) curl 'http://localhost:3000/api/bs/v2/domain' # 或用前端 token (任意客户端) curl -H 'x-bs-token: <你的token>' 'http://localhost:3000/api/bs/v2/domain' # POST curl -X POST 'http://localhost:3000/api/bs/v2/cache/refresh' \ -H 'content-type: application/json' \ -d '{"urls":["https://cdn.acme.com/a.jpg"],"type":"url"}'

目录

app/ layout.tsx page.tsx # 重定向到 /BaishanConsole.html api/ bs-env/route.ts # GET → { hasEnvToken, apiBase } bs/[...path]/route.ts # 通用代理 public/ BaishanConsole.html # 入口 HTML bs-shared.jsx # 已改为调用 /api/bs 代理 bs-icons.jsx bs-app.jsx ... # 其余面板组件 docs/ # 44 个 API 文档原文

后续工作

  • 抽离 inline CSS、把 jsx 迁到 Vite/SWC 构建管线
  • 为各面板补充缺失字段(参考 docs/
  • 加请求审计日志、限流面板、AK/SK 多账号

About

No description, topics, or website provided.
Language
TypeScript91.8%
CSS6.1%
JavaScript2.1%