白山云 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 自动注入。BS_TOKEN 环境变量(推荐,浏览器拿不到)优先;缺失时前端从 localStorage 读取并通过 x-bs-token 请求头发给代理。X-Ratelimit-* / X-Retry-After / Api-Id 原样回传。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 文档原文
docs/)