Laravel API Routes return 404 Not Found


  • | 177 points

    Hi,

    Please help with laravel api routes not but the web routes they work perfect.

    eg farmer.test works great

    but

    farmer.test/api/login 404 Not found

    when i run php artisan route:list

    the routes are there


  • | 205 points

    @thamibn Are you sure you did add the routes to api.php and not web.php??

    Please post a screenshot of "php artisan route:list".


  • | 177 points

    @JohnnyBigodes yes I did.
    what puzzle me is that when the project is outside the www folder if run PHP artisan serve and my server start on Localhost:8000 the API routes return 404 only the web routes are working,

    However if move the project to the www folder inside laragon and access the API routes via the Virtual host domain the API routes are working 100% and that's what solved my problem.

    So my question is what makes it not work on PHP artisan server and work only on virtual host domain.


  • | 205 points

    @thamibn

    Why are you serving your project with "php artisan serve"?

    You are using laragon, or not? It will serve automatically for you when you have a project inside "www".

    Go to the browser and use yourprojectname.test and it will display you project without the need to serve it through "php artisan serve".

    Laragon serves it on port 80, not like artisan that serves it on port 8000.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.