From 6974857074741e50eaba965e8f9d2718a7380b3f Mon Sep 17 00:00:00 2001 From: Last2014 Date: Wed, 10 Sep 2025 05:05:24 +0900 Subject: [PATCH] =?UTF-8?q?API=E3=81=AENotFound=E3=82=92=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=83=BB=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF=E3=82=B9=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/.htaccess | 4 ++-- api/me/settings/index.php | 2 +- api/users/follow.php | 2 +- errorpage/notfound.json | 4 ++++ settings_admin/maintenance_admin.php | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 errorpage/notfound.json diff --git a/api/.htaccess b/api/.htaccess index 40e8812..68ad3cd 100644 --- a/api/.htaccess +++ b/api/.htaccess @@ -1,8 +1,8 @@ -# --- APIはそのまま返す --- +# --- エラーハンドリング(API) --- ErrorDocument 400 "" ErrorDocument 401 "" ErrorDocument 403 "" -ErrorDocument 404 "" +ErrorDocument 404 /errorpage/notfound.json ErrorDocument 413 "" ErrorDocument 500 "" ErrorDocument 502 "" diff --git a/api/me/settings/index.php b/api/me/settings/index.php index c4c6540..d1f79a5 100644 --- a/api/me/settings/index.php +++ b/api/me/settings/index.php @@ -84,7 +84,7 @@ if (isset($_GET['token']) || (!(empty($Get_Post_Json)))) { // 文字数を確認 if (50 < mb_strlen($username, 'UTF-8')) { $error_message[] = 'ユーザーネームは50文字以内で入力してください。(USERNAME_OVER_MAX_COUNT)'; - http_response_code(400); + http_response_code(413); } } diff --git a/api/users/follow.php b/api/users/follow.php index e369912..7396f10 100644 --- a/api/users/follow.php +++ b/api/users/follow.php @@ -111,7 +111,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'error_code' => $err, 'success' => false ); - http_response_code(400); + http_response_code(500); echo json_encode($response, JSON_UNESCAPED_UNICODE); } }else{ diff --git a/errorpage/notfound.json b/errorpage/notfound.json new file mode 100644 index 0000000..c577226 --- /dev/null +++ b/errorpage/notfound.json @@ -0,0 +1,4 @@ +{ + "success": false, + "error_code": "endpoint_notfound" +} diff --git a/settings_admin/maintenance_admin.php b/settings_admin/maintenance_admin.php index 9901130..334c90e 100644 --- a/settings_admin/maintenance_admin.php +++ b/settings_admin/maintenance_admin.php @@ -151,6 +151,7 @@ RewriteRule ^.*$ /errorpage/serverstop.json [R=500,L] ErrorDocument 403 /errorpage/serverstop.php RewriteCond %{REQUEST_URI} !=/function/function.php RewriteCond %{REQUEST_URI} !=/errorpage/serverstop.php +RewriteCond %{REQUEST_URI} !=/errorpage/serverstop.json RewriteCond %{REQUEST_URI} !=/css/home.css RewriteCond %{REQUEST_URI} !=/css/color.css RewriteCond %{REQUEST_URI} !=/js/console_notice.js