accessing localhost laravel app routes to android studio failed

孤者浪人 提交于 2019-12-02 07:24:20

I'm not certain the artisan webserver listens to any requests from outside localhost. You may be able to configurate it to behave that way. Alternatively, you can host your Laravel project locally through Apache or Nginx, and configure the webserver to accept connections coming from your local network.

https://stackoverflow.com/a/24011132/9776011

https://serverfault.com/a/667800

I found it starting from here :D .
first, u can't use val BASE_URL = "http://[ip_add]:[port]/api/"
you change it to something like this:
private static final String BASE_URL = "http://my_ip_address/path/to/project/folder/relative/to/server/root"
so, it would be like this :

private static final String BASE_URL = "http://[my_ip_address]:[port]/[project_folder_name]/public/api/"


and it's done ;) ... hope it helps !

I have a php lumen project which I started usually using this command 'php -S localhost:8000 -t public' this is ok with post man as my url is "http://localhost:8000/api/v1/login"

In my Android part my base url is "http://myip:8000/api/v1/login" but it can't connect to the local server and comprehensively calling onFailour method which throwing an ecxeption can't connect to the server. So what I did I restrat the server using this command "php -S myip:8000 -t public". Then it start giving response. Caution: 1.both device device must be connect with same wifi network 2.to find your ip, go to run type cmd then in console type ipconfig hit enter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!