无法从 ripple 模拟器访问 Internet
Internet not accessible from ripple emulator
我创建了一个 VS Cordova 项目,需要从 Web 服务下载一些数据,但 Ripple 在 Chrome 中运行,并且 Chrome 认为该请求 "cross-domain" 并阻止了它.将 ripple 代理选项设置为 disabled/local/remote 无效。我可以使用 --web-security-disabled 命令行选项启动另一个 Chrome 实例,将其指向相同的 URL http://localhost:4409/... 应用程序在第二个 Chrome。现在我需要的是找到一种方法,当我在 Visual Studio 中按 F5 启动它时将 --web-security-disabled 传递给 Chrome。它可能在某个配置文件中的某处,只需要找到它...
如果不查看确切的代码很难知道,但很可能正在发生以下几种情况之一:
- 您的代码正在绕过 Ripple 中的 CORS 代理
- 通过 Ripple 代理导致网络服务器拒绝请求。
- 您在 Chrome 中安装了 Ripple 扩展程序。实际上,您最终会得到两个 Ripples 运行,这可能会导致许多意外行为。
要了解发生了什么,请确保将 CORS 代理设置为 "local" 并检查网络选项卡。对 www.bing.com 的 XHR 调用看起来像这样:
http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//www.bing.com
尝试从您的 index.html 页面执行此操作,看看它是否成功通过代理。
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://www.bing.com", true);
xmlhttp.send();
如果您需要进一步调试或想在 Visual Studio 之外使用 Ripple,您实际上可以安装 Ripple npm 包并在 Visual Studio 之外使用它。在调试配置中构建 Android,然后转到 bld/Debug 文件夹并从命令提示符执行以下命令:
npm install -g ripple-emulator
ripple emulate android --port 12345
浏览器 Window 将出现。如果不是您的默认值,请将其粘贴到 Chrome 中并重试。然后,您可以在命令提示符中查看通过代理进行的操作。
您也可以使用相同的方法使用 Chrome 开发工具和 --web-security-disabled 来调试您的应用程序。
我创建了一个 VS Cordova 项目,需要从 Web 服务下载一些数据,但 Ripple 在 Chrome 中运行,并且 Chrome 认为该请求 "cross-domain" 并阻止了它.将 ripple 代理选项设置为 disabled/local/remote 无效。我可以使用 --web-security-disabled 命令行选项启动另一个 Chrome 实例,将其指向相同的 URL http://localhost:4409/... 应用程序在第二个 Chrome。现在我需要的是找到一种方法,当我在 Visual Studio 中按 F5 启动它时将 --web-security-disabled 传递给 Chrome。它可能在某个配置文件中的某处,只需要找到它...
如果不查看确切的代码很难知道,但很可能正在发生以下几种情况之一:
- 您的代码正在绕过 Ripple 中的 CORS 代理
- 通过 Ripple 代理导致网络服务器拒绝请求。
- 您在 Chrome 中安装了 Ripple 扩展程序。实际上,您最终会得到两个 Ripples 运行,这可能会导致许多意外行为。
要了解发生了什么,请确保将 CORS 代理设置为 "local" 并检查网络选项卡。对 www.bing.com 的 XHR 调用看起来像这样:
http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//www.bing.com
尝试从您的 index.html 页面执行此操作,看看它是否成功通过代理。
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://www.bing.com", true);
xmlhttp.send();
如果您需要进一步调试或想在 Visual Studio 之外使用 Ripple,您实际上可以安装 Ripple npm 包并在 Visual Studio 之外使用它。在调试配置中构建 Android,然后转到 bld/Debug 文件夹并从命令提示符执行以下命令:
npm install -g ripple-emulator
ripple emulate android --port 12345
浏览器 Window 将出现。如果不是您的默认值,请将其粘贴到 Chrome 中并重试。然后,您可以在命令提示符中查看通过代理进行的操作。
您也可以使用相同的方法使用 Chrome 开发工具和 --web-security-disabled 来调试您的应用程序。