【发布时间】:2018-12-20 05:05:43
【问题描述】:
我正在使用 Laravel 5.7 创建 REST API,它总是返回 302 和重定向响应,HTML 代码如下
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url=http://localhost/Ozone/en" />
<title>Redirecting to http://localhost/Ozone/en</title>
</head>
<body>
Redirecting to <a href="http://localhost/Ozone/en">http://localhost/Ozone/en</a>.
</body>
{
"status": false,
"message": "Input are not valid",
"error":
{
"contact_number": ["The contact number has already been taken."]
}
}
我只想要类似 JSON 响应
{
"status": false,
"message": "Input are not valid",
"error": {
"contact_number": ["The contact number has already been taken."]
}
}
请帮帮我
【问题讨论】:
-
您的请求是否有
Accept:application/json请求标头值? -
是接受:application/json
-
如果框架返回重定向是因为您使用的是 FormRequest 和规则?我说的对吗?