我正在尝试在我的 laravel vue 应用程序中获取当前用户。每当我尝试获取它时,我都会收到此错误:
Symfony\Component\Routing\Exception\RouteNotFoundException:路由 [login] 未定义。在文件 C:\Users\Moeme\Documents\School\HsLeiden\Keuzevakken\IKFRAM\sla ticketsystem\ticketsystem\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php 第 444 行
这是我在 postman 中发送的内容:
这是我的routes\api.php
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
我真的不知道为什么它不起作用
感谢帮助
最佳答案
在头部添加新的配置
"Accept"=>"application/json"
Laravel 会检查“Accept”的配置,如果“Accept”没有设置默认值,它将返回网页或 html
https://stackoverflow.com/questions/69533769/