title: CORS requests in electron js
body: <p>I am developing a react application (chat app) using electron js (for desktops) I want to make Http requests to certain websites, to get URL metadata (opengraph, schema.org, twitterCard, etc). This cannot be done without disabling the webSecurity in electronJS.</p>
  
  <p>a) is it a good idea to disable webSecurity in electron JS ? since users can send others pretty much anything ?</p>
  
  <p>b) I have managed to achieve this using electron net package. I used it in react (renderer process) and it works smoothly, no need to disable webSecurity. however when a invalid URL is provided it throws an exception in main process (net::ERR_NAME_NOT_RESOLVED) which pops a error dialog box. is there a way to catch this exception in the renderer process?</p>
  
  <p>below is how I used electron net package.</p>
  
  <pre><code>const {net} = window.require('electron').remote
  
  function ScrapeMeta(url) {
  var promise = new Promise((resolve, reject) =&gt; {
      const options = {
          url: url,
          timeout: 2000
      };
      const request = net.request(options)
      request.on('response', (response) =&gt; {
          var body = '';
          response.on('data', function (d) {
              body += d;
          });
          response.on('end', () =&gt; {
              if (response.statusCode == 200) {
                  ParseMeta(body)
                      .then(meta =&gt; resolve(meta))
                      .catch(err =&gt; reject(err))
              } else {
                  reject("request failed with " + response.statusCode);
              }
          })
      })
      request.end();
  })
  return promise;
  </code></pre>
  
  <p>}</p>
  
  <p>What is the best way to achieve this. thanks.</p>