How to access the node api from a remote page in electron?


In my electron app , I load the remote page(index.html) from remote url like(“http://xxxx/index.html”), then I am trying to send a ipc event to the main process then handle it , and failed, but if I put the the index.html in local fs and it is OK.

So my question is how to enable the page to access the node api (like require,ipc, etc.) from the remote page.

------ (main process)

  mainWindow = new BrowserWindow({width: 800, height: 600});
  // and load the index.html of the app.
  //mainWindow.loadUrl('file://' + __dirname + '/index.html');
var ipc = require('ipc');
  ipc.on('spawn-ext-process', function () {

--------- http://localhost:8080/index.html (render process)

    var ipc = require('ipc');


From what I understand, if you host your files outside of Electron, you won’t be able to access the Electron APIs: