可以直接在server配置
server {
error_page 403 /respon_403.json;
location = /respon_403.json {
default_type application/json;
return 403 '{"code":"403","status":"error","message":"Forbidden"}';
}
error_page 404 /respon_404.json;
location = /respon_404.json {
default_type application/json;
return 403 '{"code":"404","status":"error","message":"Not Found"}';
}
error_page 500 502 503 504 /respon_500.json;
location = /respon_500.json {
default_type application/json;
return 403 '{"code":"500","status":"error","message":"Server Error"}';
}
}
nginx 错误页面替换成json格式返回
最新推荐文章于 2022-11-30 10:57:19 发布