fix: exclude management paths from request history

This commit is contained in:
2026-07-10 07:38:13 +08:00
parent f62c4d2fed
commit 92d3845eca
2 changed files with 41 additions and 1 deletions
+12 -1
View File
@@ -3581,6 +3581,7 @@ function buildEditableConfig(currentConfig, payload) {
async function handleManagementRequest(runtime, req, res, requestUrl) {
const pathname = normalizePath(requestUrl.pathname);
const isManagementPath = pathname === ADMIN_BASE_PATH || pathname.startsWith(`${ADMIN_BASE_PATH}/`);
const accessEnabled = managementAccessEnabled(runtime.config);
const accessGranted = hasManagementAccess(req, requestUrl, runtime.config);
@@ -3628,7 +3629,7 @@ async function handleManagementRequest(runtime, req, res, requestUrl) {
return true;
}
if (accessEnabled && !accessGranted && pathname.startsWith(`${ADMIN_BASE_PATH}/`)) {
if (accessEnabled && !accessGranted && isManagementPath) {
jsonResponse(req, res, 401, managementUnauthorizedPayload(), {
"cache-control": "no-store",
"set-cookie": clearManagementAccessCookieHeaders(),
@@ -4073,6 +4074,16 @@ async function handleManagementRequest(runtime, req, res, requestUrl) {
return true;
}
if (isManagementPath) {
jsonResponse(req, res, 404, {
error: {
message: "管理面路径不存在",
code: "management_endpoint_not_found",
},
});
return true;
}
return false;
}