Hello @hihi25
Here you open a closure for a route but also try to register more routes.
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
Route::post('usuario/pruebas','UserController@pruebas');
Route::get('/register','UserController@register');
Route::post('/login','UserController@login');
});
If that isn't a copy past error you could change it in:
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::post('usuario/pruebas','UserController@pruebas');
Route::get('/register','UserController@register');
Route::post('/login','UserController@login');
Else my first question is: What is the url you did test?
By default the api route file is prefixed by /api
, that means your login url in this file is: yourdomain.tld/api/login
Sidenote: I placed your code in a code block to make it more readable on this site :)
faisal liked this reply
The middleware('auth:api') tests whether a user is already logged in, and if they are, then they allow access to the routes, you need to remove the register and login routes from that middleware. You could even make your own custom middleware, that protects these routes from users that are already logged in.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community