优化直接访问API端口地址返回404不泄漏信息

This commit is contained in:
2026-04-01 10:55:12 +08:00
parent 9f42cffd18
commit a8973d4e47
5 changed files with 143 additions and 222 deletions

15
server/app/view/404.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $message ?></title>
<style>
body { font-family: system-ui, sans-serif; text-align: center; margin-top: 4rem; color: #333; }
h1 { font-size: 1.5rem; font-weight: 600; }
</style>
</head>
<body>
<h1><?= $message ?></h1>
</body>
</html>

View File

@@ -53,3 +53,6 @@ Route::group('/api', function () {
})->middleware([
TokenMiddleware::class,
]);
// 关闭主应用默认路由(/controller/action 隐式映射),未在本文件显式注册的路径返回 404
Route::disableDefaultRoute('');

View File

@@ -12,3 +12,5 @@ Route::group('/tool/install', function () {
Route::get('/online/storeAppVersions', [plugin\saipackage\app\controller\InstallController::class, 'storeAppVersions']);
Route::post('/online/storeDownloadApp', [plugin\saipackage\app\controller\InstallController::class, 'storeDownloadApp']);
});
Route::disableDefaultRoute('saipackage');