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

系统教程 行业动态 更新时间:2024-06-14 17:03:54
如何在开发过程中使用json代理访问远程服务(How to use json proxy to access remote services during development)

这是我经历过后的疑问

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

Ajax调用如何在移动应用程序(PhoneGap)中运行,而不是在PC浏览器中运行?

据此,我们可以在移动设备中使用json代理而不是jsonp,但不能在桌面浏览器中使用。 这听起来不错但我的问题是我使用我的桌面作为开发环境和浏览器是测试和调试我正在做的任何事情的最快方法但是如果我使用json代理这将因为跨域问题而无法工作。 请提供一些方法,以便我可以在桌面上轻松开发和调试应用程序。

我的工作站有Ubuntu操作系统,我使用Chrome浏览器进行测试。

This is my doubt after going through

How to send headers while using jsonp proxy?

and

How Ajax call is working in mobile app (PhoneGap), but not in PC browser?

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.

My workstation has Ubuntu OS and I use Chrome browser for testing.

最满意答案

我认为出于开发目的,您可以在浏览器中禁用跨域策略,如此处所示 。

为您桌面上的Chrome浏览器创建快捷方式 将以下标志添加到快捷方式--disable-web-security

要么

您可以设置您的开发服务器以允许此处给出的跨域请求或[此处]

1 。 将以下标题添加到您的响应Access-Control-Allow-Origin: *

I think for the development purpose you can disable cross domain policy in your browser as given here.

create a short cut for the chrome browser in you desktop add the following flag to the short cut --disable-web-security

Or

You can setup your dev server to allow cross domain requests as given here or [here]

1. Add the following header to your response Access-Control-Allow-Origin: *

更多推荐

本文发布于:2023-04-24 14:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/300d406ad79d96de48efb746ce7e2a63.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过程中   如何在   json   proxy   development

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!