0

Laravel 9 API works with localhost but not with device IP

I have my Laravel 9 installed inside xampp/htdocs. It works fine when I use API URL with localhost but it throws 404 when I use my device's IP address. http://localhost/myapp/public/api/users It works fine and returns me all the users but http://192.168.254.6/myapp/public/api/users gives me 404. Due to this I am not able to access the app from local network too. I simply tested the case with only one php file test.php and http://192.168.254.6/testapp/test.php works fine. I logged the incoming requests in index.php inside Laravel public directory and I found that Laravel is receiving the requests but when I tried to log the requests inside a controller and even inside a middleware, I got nothing. What might be the reason for it?

30th Mar 2022, 8:21 AM
Subin Gyawali
Subin Gyawali - avatar
1 Answer
0
Values in the .env are false or something in the cors.php? Maybe you don't allow other origins? Or something in your apache config
30th Mar 2022, 2:11 PM
Sebastian
Sebastian - avatar