fix: exclude management paths from request history
This commit is contained in:
+12
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user