If you want to protect API by authentication, just wrap routes into auth:auth middleware that's already present out of the box. If you're using some of the latter versions of Laravel, chances are you've got it prepared already - take a look at routes/api.php.
You might want to do something like:
Route::middleware('auth:api')->group(function () {
// put your API endpoints here
});
Hi xkrupal2, I have created the api and its working fine on my local environment but when I tested on server, it produced 404 error. It worked fine when I tried it through postman but when I called api from another page, it gave 404.