总的来说,几天前我在 laravel10 + vuejs3 上创建了一个应用程序。今天我写了一份授权说明并留下了请求,一切正常。安装扩展以使用jwt后,我将授权重写为:
public function login(LoginRequest $request): JsonResponse
{
$credentials = $request->only('email', 'password');
$token = Auth::attempt($credentials);
if ($token === false) {
return response()->json([
'status' => 'error',
'message' => 'Unauthorized',
], 401);
}
$user = Auth::user();
return response()->json([
'status' => 'success',
'user' => $user,
'authorisation' => [
'token' => $token,
'type' => 'bearer',
]
]);
}
答案开始下降,出现 500 错误,
"Malformed UTF-8 characters, possibly incorrectly encoded"
错误本身指向这里。
file:"D:\\OpenServer\\domains\\my_project\\testLara\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\JsonResponse.php"
line: 88
有谁知道如何解决这个问题?