Resolved: How to access Main process - API from render process [webRequest,session etc]


#1

Hi,

I am using webRequest from main.js

session.defaultSession.webRequest.onBeforeRequest(['*://*./*'], function(details, callback) {
     console.log(details.url)
});

How do I use the same code in render process.
I tried with remote but don’t know how to do that exactly.


#2

require('electron').remote.session

as stated here electron/docs/api/remote.md


#3

Hi,

Thanks for suggestion.
That is working

const {session} = require('electron').remote
session.defaultSession.webRequest.onBeforeRequest(['*://*./*'], function(details, callback) {
     alert('I am inside on before request')
});