How can I intercept some return HTTP request to a custom file?

I use

win.loadURL('http://example.com/index.html')

      

to load the page and I want to intercept this request to return to a custom file like:

protocol.interceptStringProtocol('http', (request, callback) => {
   ...
   callback({
     data: fs.readFileSync(path.normalize(${__dirname}/index.html), 'utf-8')
   })
})

      

this will intercept all HTTP requests from this page. How can I only intercept some HTTP requests?

+3


source to share





All Articles