Reputation: 839
I am building an api into an existing laravel application. I followed the tutorial in the docs adn using postman I am trying to call an endpoint but keep getting pushed into my web.php routes. In there I have the following at the bottom:
Route::get('{catchall}', ['as' => 'url', 'uses'=>'PagesController@getPage'])->where('catchall', '(.*)');
Which catches all the pages that do not have routes and sends them to a 404 page. The api calls are getting to that route and returning the 404. Why are they not hitting the api.php file first?
Upvotes: 1
Views: 226
Reputation: 1264
You need to add api prefix in url to call api.php, like if you have home route in api.php then call it like:
Http://127.0.0.1:8000/api/login
Upvotes: 1
Reputation: 763
First, test your API endpoints using POSTMAN.
Request URL should be something like http://127.0.0.1:3000/api/login. Remember /api/ in the path
Use Accept:application/json
in request header.
Upvotes: 1