When creating an Electron app, you might find yourself having to deal with interprocess communication (IPC). However, you can use the familiar client-server communication approach from web development. Without starting a local server. For better understanding, please refer to the article.
npm install electron-client-server electron
First, import the library in your main module (where the Electron app is initialized):
import { applyProxy } from "electron-client-server"
Then declare a constant containing the URL at which your frontend can reach the backend.
const baseURL = new URL("http://app.local/")
After your Electron app finished initializing, apply the proxy:
app.whenReady().then(() => {
applyProxy(baseURL, server)
})
There is also an example project in the example
folder of the repository.