Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thamibn's avatar

Laravel API Routes 404 Not Found

Hi,

Please help with laravel api routes not working 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

tried to clear everything by running php artisan optimize:clear

0 likes
6 replies
tykus's avatar

Are you trying to GET a POST route?

There is not a lot to work with here...

thamibn's avatar

Yes i am trying to POST on the /api/login and postman return 404 Not found

but the homepage and other web routes works perfectly

tykus's avatar

Can you show the relevant output from your php artisan routes:list command?

Is there anything special about how you define your API routes; are they defined in the web.php or api.php file?

thamibn's avatar

I have just figured it out, i was missing the prefix my bad thank you very much for your assistance

byteninja's avatar

i have a similar challenge what is the solution works fine on local machine

lemmon's avatar

@byteninja

Start a new thread and post the details of your problem there you will be more likely to get help because this post is a year old :)

Please or to participate in this conversation.