【问题标题】:Ionic Android Accessing Local Sites Set By /etc/hostsIonic Android 访问由 /etc/hosts 设置的本地站点
【发布时间】:2018-02-21 16:50:22
【问题描述】:

在我的本地笔记本电脑上,我有一堆使用 docker 运行的网站,并且可以在我的 /etc/hosts 中访问,如下所示:

> 127.0.0.1       www.example.local
> 127.0.0.1       api.example.local
> 127.0.0.1       connect.exampe.local

使用 Ionic 我正在模拟 android:ionic cordova emulate android

现在,当我在 android 上安装浏览器并在 www.example.local 中输入它时,我无法访问该站点。但它在我当地工作得很好。我假设他们将使用名称网络设置。我缺少什么配置?

【问题讨论】:

    标签: android android-studio networking ionic-framework ionic2


    【解决方案1】:

    我想这个设备的行为方式与虚拟机类似。在这种情况下,网络是桥接的,但不同。此设备上的 127.0.0.1 可能指向设备本身。您需要找到(或创建)您的设备熟悉的计算机 ip

    如果您在 Mac 上运行,您可以使用以下命令创建设备应该能够看到的环回适配器的别名。

    (注意:您在 /etc/hosts 中设置的 dns 可能不起作用)

    ifconfig lo0 alias 172.16.123.1 # Allows emulator to use 172.16.123.1 for localhost
    ifconfig lo0 -alias 172.16.123.1 # removes alias
    

    此信息的来源: https://stackoverflow.com/a/624660/1991100

    【讨论】:

      猜你喜欢
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-18
      • 1970-01-01
      • 2016-01-10
      • 1970-01-01
      • 2014-10-20
      相关资源
      最近更新 更多