Visual Studio、Ripple Emulator 和 CORS/跨域 Ajax [英] Visual Studio, Ripple Emulator and CORS/Cross Domain Ajax

查看:30
本文介绍了Visual Studio、Ripple Emulator 和 CORS/跨域 Ajax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在处理多设备混合应用程序时遇到了 Visual Studio 问题.当我尝试对外部 Web 服务进行 ajax 调用时,出现一些涟漪错误.(跨域安全问题).我的代码在部署到移动设备时运行良好.

I have an issue with Visual Studio when working on a multi device hybrid app. When I try do to an ajax call to an external webservice, and get some errors in ripple. (Cross Domain Security issues). My code works fine when deploying to a mobile device.

从研究中我发现了以下几点:

  • Ripple 有自己的代理设置

  • Ripple has its own proxy settings

  • 在 Ripple 中,转到设置,然后在代理设置上选择本地、禁用或远程(取决于您的情况).
  • 这似乎对某些人有效,但我现在遇到了不同的错误.(错误请求)

我发现更多信息表明 Chrome 可以在无网络安全模式下通过运行时的命令行开关启动.

I found more info that Chrome can be started in no web security mode, by means of a command line switch when you run it.

  • 问题在于,Visual Studio 似乎对 Chrome 的路径进行了硬编码,用于打开涟漪.
  • 因此,我无法在没有网络安全模式的情况下启动 Chrome...

推荐答案

我和 Louis 遇到了完全相同的问题,但是从 Chrome 48 开始,所有 CORS 扩展似乎都停止工作了.我想出了一个我认为可以分享的替代解决方案.

I had exactly the same problem as Louis, but since Chrome 48 all the CORS extensions seem to have stopped working. I've come up with an alternative solution which I thought I'd share.

  1. 在您的 Chrome 安装目录中 - 可能是 C:Program Files (x86)GoogleChromeApplication - 创建 chrome.exe 的快捷方式
  2. 右键单击此快捷方式并选择属性"
  3. 在快捷方式选项卡的目标字段中,附加以下两个字段 --allow-file-access-from-files --disable-web-security4 .保存并将快捷方式重命名为Google Chrome - Debug with Ripple"
  4. 右键单击它并选择固定到开始菜单

此快捷方式将允许您在没有网络安全性的情况下运行 Chrome,从而允许 Ripple 中的 CORS.通过使用快捷方式,这不会干扰您对 Chrome 的正常使用.现在为了使用Ripple

This shortcut will allow you to run Chrome with no web security, which allows CORS in Ripple. By using a shortcut this will not interfere with your normal use of Chrome. Now in order to use Ripple

  1. 在 Visual Studio 中调试您的应用,该应用将在其自己的 Chrome 实例中启动 Ripple
  2. 现在打开开始菜单并点击固定的Google Chrome - Debug with Ripple"快捷方式
  3. Chrome 的第二个实例将启动并显示警告您正在使用不受支持的命令行标志:--disable-web-security.稳定性和安全性将受到影响."
  4. 将 Ripple 代理 URL 从 Visual Studio 实例复制到这个新实例,例如 http://localhost:4400/index.html?enableripple=cordova-3.0.0-NexusS
  5. 您的 CORS 请求现在可以在 Ripple 中运行.

请注意,Visual Studio 刚刚用于启动 Ripple.需要使用 Chrome 的开发者工具进行调试.

Note that Visual Studio has just been used to launch Ripple. Debugging will need to take place using Chrome's Developer Tools.

另请注意,您可以通过浏览到 url chrome://version/来仔细检查 Chrome 是否正在使用您的快捷方式标志

Note also that you can double check that Chrome is using your shortcut flags by browsing to the url chrome://version/

希望这有帮助!

这篇关于Visual Studio、Ripple Emulator 和 CORS/跨域 Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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