How can I intercept some HTTP request fallback to custom file?


#1

I use win.loadURL(‘http://example.com/index.html’) to load a page, and I want to intercept this request fallback to 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 do only intercept some HTTP requests?