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

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

问题描述

我们正在使用 Atom Shell(目前称为 electron)将 Web 应用程序包装为桌面由于 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. Does Atom Shell (Electron) restrict 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天全站免登陆