I am developing an offline app and would like to disable networking for security purposes.
Is that possible? If so, how? Thanks for helping out!
I am developing an offline app and would like to disable networking for security purposes.
Is that possible? If so, how? Thanks for helping out!
This answer only works on the renderer process, not on the main process
You may want to use network emulation:
const { session } = require('electron');
session.defaultSession.enableNetworkEmulation({
offline: true,
});
// Or
window.webContents.session.enableNetworkEmulation({
offline: true,
});
It probably is equivalent to opening the devtools and using network throttling.
On the documentation: https://www.electronjs.org/docs/latest/api/session#sesenablenetworkemulationoptions