Back

routes - weird behaviour


andrea posted 3 months ago

Hello, I have these customer's routes:

Route::get('customers', '[email protected]'); Route::post('customers', '[email protected]'); Route::get('customers/create', '[email protected]'); Route::get('customers/{id}/edit/{address_id}', '[email protected]'); Route::get('customers/{id}/delete', '[email protected]'); Route::patch('customers/{id}/update', '[email protected]'); Route::get('customers/{id}/addaddress', '[email protected]'); Route::post('customers/toggleLegalOffice', '[email protected]'); Route::post('customers/toggleFavorite', '[email protected]'); Route::post('customers/toggleCanOrder', '[email protected]'); Route::post('customers/getPayment', '[email protected]'); Route::get('customers/{id}/destinations', '[email protected]'); Route::get('customers/{id}/deleteaddress', '[email protected]'); Route::get('customers/{id}/editaddress', '[email protected]'); Route::patch('customers/{id}/saveaddress', '[email protected]'); Route::get('customers/import', '[email protected]'); Route::post('customers/import', '[email protected]');

when I browse customers/import on my local dev machine everything is fine, but when I try on production machine I get:

The GET method is not supported for this route. Supported methods: PATCH

how can this be? Thanks a lot

TorchSK replied 3 months ago

Run

php artisan cache:clear
php artisan route:cache

on prod server

andrea replied 3 months ago

thanks for your answer: cache:clear was ok, but route:cache gives me

Route cache cleared!

   LogicException  : Unable to prepare route [api/user] for serialization. Uses Closure.

  at /var/www/intranet/vendor/laravel/framework/src/Illuminate/Routing/Route.php:917
    913|      */
    914|     public function prepareForSerialization()
    915|     {
    916|         if ($this->action['uses'] instanceof Closure) {
  > 917|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    918|         }
    919|
    920|         $this->compileRoute();
    921|

  Exception trace:

  1   Illuminate\Routing\Route::prepareForSerialization()
      /var/www/intranet/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      /var/www/intranet/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

  Please use the argument -v to see more details.

and the problem is still there. thanks

TorchSK replied 3 months ago

this is a bug in Laravel from what I know. If you are not using routes in api.php... just delete all routes in api.php file

and try again


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us