Cross Domain Ajax Call in Atom Shell

前端 未结 3 1172
小蘑菇
小蘑菇 2021-02-08 02:48

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.

3条回答
  •  攒了一身酷
    2021-02-08 03:17

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

    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 }
    });
    

提交回复
热议问题