首页不需要token

This commit is contained in:
huangxd- committed 2025-09-12 18:39:27 +08:00
1 parent 49c4c6845f
commit cfda92d6ea
1 file changed
+10 -10
+10 -10
View File
@@ -207,6 +207,16 @@ async function handleRequest(req, env) {
let path = url.pathname;
const method = req.method;
// GET /
if (path === "/" && method === "GET") {
log("log", "Accessed homepage with repository information");
return jsonResponse({
message: "Welcome to the Danmu API server",
repository: "https://github.com/huangxd-/danmu_api.git",
notice: "本项目仅为个人爱好开发,代码开源。如有任何侵权行为,请联系本人删除。"
});
}
// --- 校验 token ---
const parts = path.split("/").filter(Boolean); // 去掉空段
if (parts.length < 2 || parts[0] !== token) {
@@ -219,16 +229,6 @@ async function handleRequest(req, env) {
// 移除 token 部分,剩下的才是真正的路径
path = "/" + parts.slice(1).join("/");
// GET /
if (path === "/" && method === "GET") {
log("log", "Accessed homepage with repository information");
return jsonResponse({
message: "Welcome to the Danmu API server",
repository: "https://github.com/huangxd-/danmu_api.git",
notice: "本项目仅为个人爱好开发,代码开源。如有任何侵权行为,请联系本人删除。"
});
}
// GET /api/v2/search/anime
if (path === "/api/v2/search/anime" && method === "GET") {
return searchAnime(url);