skip to Main Content

Unable to prepare route [api/user] for serialization. Uses Closure. at vendor/laravel/framework/src/Illuminate/Routing/Route.php:1150

2

Answers


  1. pls run php artisan route:list and check if there is any Closure in that list.

    Login or Signup to reply.
  2. You can’t cache routes if you are using a closure. The closure is this part
    public function (Request $request) { return $request->user(); }

    Instead, if you move the code into a controller you’ll be able to cache the routes and eliminate the error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search