From ce9f69a76e6f94ddb1671350a12e40e5bf195f13 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sat, 19 Sep 2026 17:02:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9F=8B=E7=82=B9=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E5=85=BC=E5=AE=B9/api=E5=89=8D=E7=BC=80(originalUrl=E5=90=AB?= =?UTF-8?q?=E5=89=8D=E7=BC=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/index.js b/server/src/index.js index 94a6a93..b200f18 100755 --- a/server/src/index.js +++ b/server/src/index.js @@ -68,12 +68,12 @@ app.use('/api/', limiter) // 访问埋点:记录页面级 GET 请求(排除管理后台/认证/健康检查/高频轮询接口),小程序与 H5 访问均可统计 // PV 口径:只记"页面首屏"接口(每打开一页只计1次),轮询/统计类接口不计——避免一次访问刷出6-8条 -const TRACKABLE_PAGES = [/^\/knowledge(\?|$)/, /^\/trend(\?|$)/, /^\/knowledge\/stats/, /^\/ai-chat\/quota/, /^\/user\/leaderboard/, /^\/feedback/] +const TRACKABLE_PAGES = [/^\/?api\/knowledge(\?|$)/, /^\/?api\/trend(\?|$)/, /^\/?api\/knowledge\/stats/, /^\/?api\/ai-chat\/quota/, /^\/?api\/user\/leaderboard/, /^\/?api\/feedback/] app.use('/api', (req, res, next) => { try { if (req.method === 'GET' && !req.path.startsWith('/admin') && !req.path.startsWith('/auth')) { - const path = String(req.originalUrl || req.path).split('?')[0] - const isPage = TRACKABLE_PAGES.some((re) => re.test(path)) + const fullPath = String(req.originalUrl || req.path).split('?')[0] + const isPage = TRACKABLE_PAGES.some((re) => re.test(fullPath)) || TRACKABLE_PAGES.some((re) => re.test(fullPath.replace(/^\/api/, ''))) if (isPage) { const ua = String(req.headers['user-agent'] || '') const referer = String(req.headers.referer || '')