1

I am desperatly trying to code a plugin for Draw.io that will basically do a request to another website in order to get some images.

It works fine on the local web version of Draw.io, but on the desktop version I get an empty responseText.

Here is what I'm simply doing in the plugin js:

Draw.loadPlugin(function(ui)
{
var data = null;
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://jsonplaceholder.typicode.com/posts");
xhr.setRequestHeader("accept", "application/json");

xhr.send();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
    alert(this.responseText);
    }
});
});

That is pretty basic and probably not working well but I should at least get an error... All I have is an empty response.

Does the Electron app blocks outside XHR? Is there a workaround? Thanks!

ShinaBR2
  • 2,519
  • 2
  • 14
  • 26
Docteur G
  • 11
  • 1
  • do you get any errors on the console ? – Farabi Abdelwahed Jul 08 '20 at 07:41
  • I don't have access to the console unfortunately, the draw.io app does not allow it... – Docteur G Jul 08 '20 at 08:02
  • I cloned and installed the drawio-desktop git on my desktop, the issue is a classical "VM522:4 Refused to connect to #### because it violates the following Content Security Policy directive: "connect-src 'self'"". I'm now looking for a way to allow cross requests in draw.io... – Docteur G Jul 08 '20 at 08:17
  • try adding the following to your index.js const win = new BrowserWindow({ ... webPreferences: { webSecurity: false } }); – Farabi Abdelwahed Jul 08 '20 at 08:25

0 Answers0