0

1 year agoby Sunil

How to add the middleware in api

Hi

can I write like this public function __constructor() {

    $this->middleware('auth:api');
}
	
	for adding middleware to all api
	
	wating for your reply.

88

Sarthak Shrivastava replied 1 year ago

0

Yes yes sure you can do that

0

Sunil replied 1 year ago

0

I mean can i write

auth api

	on ProductController so that all products api need authenticate.

88

Sarthak Shrivastava replied 1 year ago

0

You can use middlewar on you api.php file for all your routes

Try like this

Route::group(['middleware'=>'api'],function(){
// Here comes all your api routes
}
);
Ask Question
Most Visited
Categories