APIのNotFoundを作成・ステータスコードを修正

This commit is contained in:
Last2014 2025-09-10 05:05:24 +09:00
parent 5bc3ab0e56
commit 6974857074
5 changed files with 9 additions and 4 deletions

View File

@ -1,8 +1,8 @@
# --- APIはそのまま返す --- # --- エラーハンドリング(API) ---
ErrorDocument 400 "" ErrorDocument 400 ""
ErrorDocument 401 "" ErrorDocument 401 ""
ErrorDocument 403 "" ErrorDocument 403 ""
ErrorDocument 404 "" ErrorDocument 404 /errorpage/notfound.json
ErrorDocument 413 "" ErrorDocument 413 ""
ErrorDocument 500 "" ErrorDocument 500 ""
ErrorDocument 502 "" ErrorDocument 502 ""

View File

@ -84,7 +84,7 @@ if (isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
// 文字数を確認 // 文字数を確認
if (50 < mb_strlen($username, 'UTF-8')) { if (50 < mb_strlen($username, 'UTF-8')) {
$error_message[] = 'ユーザーネームは50文字以内で入力してください。(USERNAME_OVER_MAX_COUNT)'; $error_message[] = 'ユーザーネームは50文字以内で入力してください。(USERNAME_OVER_MAX_COUNT)';
http_response_code(400); http_response_code(413);
} }
} }

View File

@ -111,7 +111,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
'error_code' => $err, 'error_code' => $err,
'success' => false 'success' => false
); );
http_response_code(400); http_response_code(500);
echo json_encode($response, JSON_UNESCAPED_UNICODE); echo json_encode($response, JSON_UNESCAPED_UNICODE);
} }
}else{ }else{

4
errorpage/notfound.json Normal file
View File

@ -0,0 +1,4 @@
{
"success": false,
"error_code": "endpoint_notfound"
}

View File

@ -151,6 +151,7 @@ RewriteRule ^.*$ /errorpage/serverstop.json [R=500,L]
ErrorDocument 403 /errorpage/serverstop.php ErrorDocument 403 /errorpage/serverstop.php
RewriteCond %{REQUEST_URI} !=/function/function.php RewriteCond %{REQUEST_URI} !=/function/function.php
RewriteCond %{REQUEST_URI} !=/errorpage/serverstop.php RewriteCond %{REQUEST_URI} !=/errorpage/serverstop.php
RewriteCond %{REQUEST_URI} !=/errorpage/serverstop.json
RewriteCond %{REQUEST_URI} !=/css/home.css RewriteCond %{REQUEST_URI} !=/css/home.css
RewriteCond %{REQUEST_URI} !=/css/color.css RewriteCond %{REQUEST_URI} !=/css/color.css
RewriteCond %{REQUEST_URI} !=/js/console_notice.js RewriteCond %{REQUEST_URI} !=/js/console_notice.js