Atom Shell中的跨域Ajax调用 [英] Cross Domain Ajax Call in Atom Shell

查看:72
本文介绍了Atom Shell中的跨域Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在与Atom Shell(当前称为 electron )合作,将网络应用包装为桌面应用并且由于CORS限制而无法进行跨域Ajax调用。

We are working with Atom Shell (Currently known as electron) to wrap a web application as desktop app and having trouble making cross domain ajax calls due to CORS restriction.

我们还尝试了 nw.js (以前称为Node -Webkit),并且使用它进行跨域Ajax调用就没有问题。默认情况下,Atom Shell(Electron)是否限制跨域调用?

We also tried nw.js (Formerly known as Node-Webkit) and we had no problem making cross domain ajax call with it. Is Atom Shell (Electron) restricts cross domain calls by default ?

推荐答案

如果网页加载在 file://中模式,并且不由http服务器提供服务,默认情况下可以进行Ajax调用。

If the webpage is loaded in "file://" mode and not served by an http server, you can make ajax calls by default.

如果您仍然对CORS限制有疑问,可以将此选项设置为浏览器-窗口对象:

If you still have troubles with CORS restrictions, you can set this option to the browser-window object :

var BrowserWindow = require('browser-window');
var win = new BrowserWindow({
  webPreferences: { webSecurity: false }
});

这篇关于Atom Shell中的跨域Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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