Clear Laravel 5.1 Set with a single RESTful route receiving a NotFoundHttpException

I use Laravel 5 as an API for an Ionic app, and it seems to almost work, but my test route is in Laravel

Route::group( [ 'prefix' => 'api' ], function ()
{
    Route::any( 'user', function ()
    {
        return 'Hello Anonymous User';
    } );
} );

When i clicked

http://localhost:8000/api/user

It should just return "Hello Anonymous User", but since switching to Homestead instead of using artisan serves, it now throws this error:

Sorry, the page you are looking for could not be found.

NotFoundHttpException in RouteCollection.php line 145:
in RouteCollection.php line 145
at RouteCollection->match(object(Request)) in Router.php line 719
at Router->findRoute(object(Request)) in Router.php line 642
at Router->dispatchToRoute(object(Request)) in Router.php line 618
at Router->dispatch(object(Request)) in Kernel.php line 210
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53

And any message from Ionic using ngResource for the API is returned as a 500 error in the console. I found one solution that suggested disabling the VerifyCsrfToken middleware in app / http / Kernel.php, commenting:

\App\Http\Middleware\VerifyCsrfToken::class,

but this did not work or did not change the error.

http://localhost:8000/ Laravel 5 debugbar. http://localhost:8000/user, .

UPDATE

.

php artisan route:list

| GET|HEAD                       | /                 | Closure
| GET|HEAD|POST|PUT|PATCH|DELETE | api/user          | Closure
| GET|HEAD|POST|PUT|PATCH|DELETE | user              | Closure

... with debugbar routes
+4
1

, , , , . , , dd ( "ping" ) . , , .

/etc/hosts (, OS X * nix) , 192.168.10.10, someappname.app ~ ~/.homestead/Homestead.yaml , : ,

-map: someappname.app
 to: /home/whatever the mapped path to this app is

~/Homestead , , .

, .

+1

All Articles