Calling API routes in Laravel

In Laravel 5.3  the API routes are moved to api.php file. Suppose you have created a route as given below.


return "ok";


Normally you will call the route with a url like, http://localhost:8080/test/public/test. It will give a NotFoundHttpException.

Instead write a url like this

which will return the page for you.

In the RouteServiceProvider.php the API prefix for API routes are set as default.

protected function mapApiRoutes()



        'middleware' => 'api',

        'namespace' => $this->namespace,

        'prefix' => 'api',

    ], function ($router) {

        require base_path('routes/api.php');