如何在开发过程中使用json代理访问远程服务 [英] How to use json proxy to access remote services during development

查看:222
本文介绍了如何在开发过程中使用json代理访问远程服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的疑问。

如何在使用jsonp代理时发送标题?

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.


  1. 建立您的桌面中Chrome浏览器的快捷方式

  2. 在快捷方式 - disable-web-security li>
  1. create a short cut for the chrome browser in you desktop
  2. 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
将以下标题添加到您的响应 Access-Control-Allow-Origin:*

这篇关于如何在开发过程中使用json代理访问远程服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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