Skip to content
Advertisement

using Laravel 7 Api routes

I’m trying to use simple laravel api for getting and sending requests, after define this api routes in api.php:

JavaScript

and creating AuthController in app/http/controller/Api/v1 directory:

JavaScript

i get 404 error on this link:

JavaScript

how can i resolve this problem?

Advertisement

Answer

Routes in api.php are automatically prefixed with /api. Currently, your routes are:

JavaScript

So navigating to http://127.0.0.1:8000/Api/v1/login is a 404.

If you remove /Api, and just use Route::prefix('/v1') ... then you should have no issue.

Also, always double check your routes with php artisan route:list to see what’s wrong.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement