Reputation: 11
I have an electron app built using React.js and it relies on a local Node server running on parallel to the App. How can I distribute both products in a single exe so that the Node server made separetely to the Electron app runs at the same time when executing the program?
Upvotes: 1
Views: 2880
Reputation: 965
You can just do it. There is a Node process that kicks off the whole app, which you can start your server on. Then the client code is run by whatever you start the BrowserWindow on. Then you can just make requests to localhost and your server should be able to pick them up.
That said, there are some good reasons why you should strongly consider NOT using an actual HTTP server, but using inter-process communication (IPC) instead.
Security is an issue — you’re starting a server on a client machine, and if your authentication has any flaws, you’re opening up all your server endpoints to any other process on the client, or even other machines on the local network.
Ease - IPC is well supported by Electron so it’s simply easier to develop against.
Upvotes: 1