Ionic + Cpacitor Electron, NAME_NOT_RESOLVED for socket.io requests
Describe the bug
Situation: I made a repository for testing: https://github.com/ZweiEuro/electron_socket_test
It has: server.js - minimal socket io server that just console.logs conections. CORS * so that is not an issue. Listening 3002
A minimal ionic blank project with socket-client installed. The web version just prompts for an ip address and tries to connect to it.
Mainly defined in /src/pages/Home.tsx. Always connecting to <IP>:3002
A lot of tasks defined for easier debugging.
The ionic project has https://github.com/capacitor-community/electron installed as a platform, it's data is located in /electron. It should behave the same way as the ionic web page
The Problem:
Using the app Web version:
- Running
node server.js - Running
ionic serve - Navigating browser to
http://localhost:8100/home - Entering your machines ip address in the prompt will connect to it
- Console says "connect" both for the server and the web client => works as intended
Using the app electron version: (Since electron does not support 'prompt' in their window, you need to hard code the address of the server into Home.tsx, if you do this you need to rebuild (run the tasks again)
- Using the tasks "run electron" or "pack electron" (and starting it manually)
- open electron dev tools
- See error
GET http://capacitor-electron/socket.io/?EIO=4&transport=polling&t=OGz8z5U net::ERR_NAME_NOT_RESOLVED
To me it looks like something is getting rewritten incorrectly?
To Reproduce
- clone https://github.com/ZweiEuro/electron_socket_test
npm iin both electron and the root directory- Run the commands listed above, it is easier to start vscode in the directory and using the tasks
- Web version works, electron version throws the above error