'Laravel: unexpected GET request

I am logging errors in a Laravel website.

I saw some errors like this: Error: The GET method is not supported for this route. Supported methods: POST.

Into log I also save the previous page with request()->headers->get('referer') and it is empty.

I double checked and the only call to that route is done with POST method.

Moreover the page with the form (that calls that route with POST) needs a login (middleware('auth') in Controller's construct), so bots or others should not get the action attribute and use it with GET.

Could you help me, please?

EDIT web.php

<?php
    Route::prefix('/{coNameURL}/extranet')->group(function () {
        Route::get('/', 'Extranet\Auth\LoginController@showLoginForm')->name('extranet.home');
        Route::get('/login', 'Extranet\Auth\LoginController@showLoginForm')->name('extranet.login');
        Route::post('/login', 'Extranet\Auth\LoginController@login');
        Route::post('/logout', 'Extranet\Auth\LoginController@logout')->name('extranet.logout');
        Route::get('/dashboard', 'Extranet\HomeController@dashboard')->name('extranet.dashboard');
        Route::get('/moduli/{blocco}/segnalazione', 'Extranet\ModuliController@modulo')->name('extranet.moduli.segnalazione');
        Route::post('/moduli/{blocco}/invia_segnalazione', 'Extranet\ModuliController@modulo_invia')->name('extranet.moduli.blocco_invia');
    });

EDIT: error

C:\inetpub\WEBSITE_FOLDER>php artisan cache:clear
Application cache cleared!



C:\inetpub\WEBSITE_FOLDER>php artisan route:cache
Route cache cleared!

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

  at C:\inetpub\WEBSITE_FOLDER\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()
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteCacheCommand.php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36

  Please use the argument -v to see more details.



C:\inetpub\WEBSITE_FOLDER>php artisan route:cache -v
Route cache cleared!

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

  at C:\inetpub\WEBSITE_FOLDER\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()
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteCacheCommand.php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36

  3   Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Container\Util.php:37

  4   Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:93

  5   Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37

  6   Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Container\Container.php:590

  7   Illuminate\Container\Container::call()
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Console\Command.php:134

  8   Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      C:\inetpub\WEBSITE_FOLDER\vendor\symfony\console\Command\Command.php:255

  9   Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Console\Command.php:121

  10  Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      C:\inetpub\WEBSITE_FOLDER\vendor\symfony\console\Application.php:1009

  11  Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Foundation\Console\RouteCacheCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      C:\inetpub\WEBSITE_FOLDER\vendor\symfony\console\Application.php:273

  12  Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      C:\inetpub\WEBSITE_FOLDER\vendor\symfony\console\Application.php:149

  13  Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Console\Application.php:93

  14  Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      C:\inetpub\WEBSITE_FOLDER\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:131

  15  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      C:\inetpub\WEBSITE_FOLDER\artisan:37


Solution 1:[1]

Have you tried to clear the (route) cache?

php artisan cache:clear

php artisan route:cache

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maik Lowrey