ti-click / laravel-realworld-example-app

Exemplary real world backend API built with Laravel
https://realworld.io
MIT License
0 stars 0 forks source link

http 500 error when POST /users #5

Closed dulao5 closed 2 years ago

dulao5 commented 2 years ago
curl 'http://127.0.0.1:8000/api/users' \
  -H 'Connection: keep-alive' \
  -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'Origin: http://localhost:8081' \
  -H 'Sec-Fetch-Site: cross-site' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Referer: http://localhost:8081/' \
  -H 'Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7' \
  --data-raw '{"user":{"email":"dzg@dzg.com","password":"test123","username":"dzg"}}' \
  --compressed
"Tymon\JWTAuth\Exceptions\JWTException"
"Could not create token: Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead."

[
    "#0 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/tymon/jwt-auth/src/Manager.php(84): Tymon\\JWTAuth\\Providers\\JWT\\Lcobucci->encode(Array)",
    "#1 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/tymon/jwt-auth/src/JWT.php(78): Tymon\\JWTAuth\\Manager->encode(Object(Tymon\\JWTAuth\\Payload))",
    "#2 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/tymon/jwt-auth/src/JWT.php(90): Tymon\\JWTAuth\\JWT->fromSubject(Object(App\\User))",
    "#3 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Tymon\\JWTAuth\\JWT->fromUser(Object(App\\User))",
    "#4 /Users/zuser/src/ti-click/laravel-realworld-example-app/app/User.php(51): Illuminate\\Support\\Facades\\Facade::__callStatic('fromUser', Array)",
    "#5 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(438): App\\User->getTokenAttribute(NULL)",
    "#6 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(340): Illuminate\\Database\\Eloquent\\Model->mutateAttribute('token', NULL)",
    "#7 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(313): Illuminate\\Database\\Eloquent\\Model->getAttributeValue('token')",
    "#8 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1416): Illuminate\\Database\\Eloquent\\Model->getAttribute('token')",
    "#9 /Users/zuser/src/ti-click/laravel-realworld-example-app/app/RealWorld/Transformers/UserTransformer.php(13): Illuminate\\Database\\Eloquent\\Model->offsetGet('token')",
    "#10 /Users/zuser/src/ti-click/laravel-realworld-example-app/app/RealWorld/Transformers/Transformer.php(39): App\\RealWorld\\Transformers\\UserTransformer->transform(Object(App\\User))",
    "#11 /Users/zuser/src/ti-click/laravel-realworld-example-app/app/Http/Controllers/Api/ApiController.php(47): App\\RealWorld\\Transformers\\Transformer->item(Object(App\\User))",
    "#12 /Users/zuser/src/ti-click/laravel-realworld-example-app/app/Http/Controllers/Api/AuthController.php(55): App\\Http\\Controllers\\Api\\ApiController->respondWithTransformer(Object(App\\User))",
    "#13 [internal function]: App\\Http\\Controllers\\Api\\AuthController->register(Object(App\\Http\\Requests\\Api\\RegisterUser))",
    "#14 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)",
    "#15 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('register', Array)",
    "#16 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Api\\AuthController), 'register')",
    "#17 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController()",
    "#18 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Route->run()",
    "#19 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#20 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#21 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#22 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#23 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/barryvdh/laravel-cors/src/HandleCors.php(59): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#24 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#25 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#26 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#27 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
    "#28 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))",
    "#29 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))",
    "#30 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))",
    "#31 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))",
    "#32 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))",
    "#33 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#34 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#35 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#36 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#37 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#38 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#39 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#40 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#41 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#42 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#43 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#44 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#45 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#46 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\\Cors\\HandlePreflight->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
    "#47 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
    "#48 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
    "#49 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
    "#50 /Users/zuser/src/ti-click/laravel-realworld-example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
    "#51 /Users/zuser/src/ti-click/laravel-realworld-example-app/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
    "#52 /Users/zuser/src/ti-click/laravel-realworld-example-app/server.php(21): require_once('/Users/duzhigan...')",
    "#53 {main}"
]
dulao5 commented 2 years ago

https://github.com/tymondesigns/jwt-auth/issues/2059

KhaledLela commented 1 year ago

Solution 2: fails with php 8.2

[InvalidArgumentException]
Package lcobucci/jwt at version 3.3.3 has requirements incompatible with your PHP version, PHP extensions and Compos
er version: