如何将模拟器连接到laravel服务器localhost:8000 [英] How to connect emulator to laravel server localhost:8000

查看:151
本文介绍了如何将模拟器连接到laravel服务器localhost:8000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的Android应用程序以10.0.0.2:8080连接到wampserver中的项目时,我可以连接到localhost:8080,但是我使用laravel并且我的Web服务位于localhost:8000.我想从模拟器连接到IP 10.0.0.2:8000的laravel服务器中的Web服务,但是我无法连接到它.

I can connect to localhost:8080 when my android app connect to my project in wampserver with 10.0.0.2:8080,but i use laravel and my web service is in localhost:8000. i want to connect from emulator to my web service in laravel server in IP 10.0.0.2:8000 but i can't connect to it.

10000毫秒后无法连接到/10.0.2.2(端口8000). 我尝试了localhost:8000和其他一些IP,该IP用于连接laravel服务器?

failed to connect to /10.0.2.2 (port 8000) after 10000 ms . i tried localhost:8000 and some other IP, which IP use to connect to laravel server?

推荐答案

有点晚,但是您的问题与路由有关.首先,假设您在Windows上,请转到您的hosts文件并将IP: 10.0.2.2 映射到 127.0.0.1

a bit late but your issue has to do with your routing. First of all assuming you are on windows go to your hosts file and map the IP: 10.0.2.2 to 127.0.0.1

像这样:

127.0.0.1    10.0.2.2

然后,如果已配置虚拟主机,则将IP 10.0.2.2映射到 httpd-vhosts.conf

Then if you've configured your virtual hosts map the IP 10.0.2.2 to your project directory in your httpd-vhosts.conf

赞:

<VirtualHost *:80>
    DocumentRoot "C:/www/example/"
    ServerName 10.0.0.2
    ServerAlias 10.0.0.2
</VirtualHost>

这篇关于如何将模拟器连接到laravel服务器localhost:8000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆