I'm using Laravel 5 as an API for an Ionic app, and it appears to be almost working, but my test route in Laravel
Route::group( [ 'prefix' => 'api' ], function ()
{
Route::any( 'user', function ()
{
return 'Hello Anonymous User';
} );
} );
When I hit
http://localhost:8000/api/user
Should just return "Hello Anonymous User", but since switching to Homestead instead of using artisan serve 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 post from Ionic using ngResource to the API is returned as a 500 Error in the console. I found one solution that suggested turning off VerifyCsrfToken middleware in app/http/Kernel.php by commenting out:
\App\Http\Middleware\VerifyCsrfToken::class,
but this didn't work or change the error.
I am able to hit the default welcome route at http://localhost:8000/ and see the Laravel 5 welcome view with debugbar. I also tried using just the inner route form above without the group and hit http://localhost:8000/user, but it produces the same error.
UPDATE
Checking the route list all the routes appear to be okay.
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