在开发过程中如何使用json代理访问远程服务 [英] How to use json proxy to access remote services during development
问题描述
这是我经历的怀疑
和
Ajax调用如何在移动应用程序(PhoneGap)中工作,但不在PC浏览器中?
根据这一点,我们可以使用json代理而不是jsonp在移动但不在桌面浏览器。这听起来不错,但我的问题是我使用我的桌面作为开发环境,浏览器是最快的方式来测试和调试我正在做的任何事情,但如果我使用json代理,这将无法工作,因为跨域问题。请建议我可以在桌面本身轻松开发和调试应用程序。
As per this we can use json proxy instead of jsonp in mobile but not in desktop browser. This sounds good but my problem is I am using my desktop as develop environment and browser is quickest way to test and debug whatever I am doing but if I use json proxy this won't work because of cross domain issues. Please suggest ways such that I can easily develop and debug application on my desktop itself.
我的工作站有Ubuntu操作系统,我使用Chrome浏览器进行测试。
My workstation has Ubuntu OS and I use Chrome browser for testing.
推荐答案
我认为,为了开发目的,您可以在浏览器中禁用跨域策略,其中。
I think for the development purpose you can disable cross domain policy in your browser as given here.
- 创建一个在您桌面上的Chrome浏览器的快捷方式
- 在快捷方式中添加以下标记
- disable-web-security
- create a short cut for the chrome browser in you desktop
- add the following flag to the short cut
--disable-web-security
或
您可以将开发者服务器设置为允许跨域请求此处或[这里]
You can setup your dev server to allow cross domain requests as given here or [here]
1 。
将以下标题添加到您的响应中访问控制允许原点:*
这篇关于在开发过程中如何使用json代理访问远程服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!