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
electron


source to share


No one has answered this question yet

Check out similar questions:

7
Electronic manipulation / interception of WebView requests and responses
3
How can I unregister events in the atomic shell?
2
how to access api node from remote page in electronic?
1
Webview preloading not working
1
how to get http: job request in electronic application
1
How to redirect urls to one app for html files using Electron
1
How to intercept an electron's request and return an individual response?
0
How do I download images in a local zip file in an electronic web viewer?
0
How can we transfer requests from one page to another electronically
0
Intercept https requests for only one browser window



All Articles
Loading...
X
Show
Funny
Dev
Pics