2
votes

I just created a fresh Laravel project in my localhost directory and created a Laravel route in the api.php file.

Route::post('/home', 'HomeAPI@index');

However, when I try to send a post request to the link localhost/home from Postman, it gives the following error:

Sorry, the page you are looking for could not be found.

1/1 NotFoundHttpException in RouteCollection.php line 161:

How do I access my /home route?

2
Shouldn't the route be localhost/<appname>/home? - azdonald

2 Answers

5
votes

When trying to access a API route (route mentioned in api.php) from Laravel, just add /api to the link you are trying to access. In this case, your link would be:

localhost/api/home

This should solve your problem.

2
votes

Everything in api.php is under /api so in your case it's localhost/api/home