I am doing a simple authentication using AuthController in my page. And in my route list I created a named route to login page just like this:
//authentication routes
Route::get('auth/login', [
'as' => 'login', 'uses' => 'Auth\AuthController@getLogin'
]);
But when I tried to access in my url using this:
http://localhost:8000/login
I got an error:
NotFoundHttpException in RouteCollection.php line 143:
in RouteCollection.php line 143
at RouteCollection->match(object(Request)) in Router.php line 746
at Router->findRoute(object(Request)) in Router.php line 655
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
...
Can you help me with this?
Answer:
It should be:
Route::get('login', [
'as' => 'login', 'uses' => 'Auth\AuthController@getLogin'
]);
Answer:
The name "login" "as" parameter is only for referring to the route when you need a URL generated or something like that. Your code does not mean that you can got to the path /login. To do that, you need to set the route like so:
Route::get('login', [
'as' => 'login', 'uses' => 'Auth\AuthController@getLogin'
]);
To visit the route as you set, you need to go to: http://localhost:8000/auth/login
No comments:
Post a Comment