I have done a little Chat-App -> React JS Chat Client and Node-JS (socket.io / express) Web-Socket server.
After I finished testing I deployed the NodeJS-Web-Socket server on heroku.
The URL I should use in the Client is const ENDPOINT = 'https://jorroch-consulting.herokuapp.com/';
What makes me wondering is that I had to use a port in the endpoint URL, when my server still was started on localhost.
The URL looked like this: const ENDPOINT = 'localhost:5000';
That was because my server was listening to port 5000:
server.listen(PORT, () => console.log('Server has started on port ${PORT}'));
Now, that the server is deployed on heroku the client does not have the info about the port 5000 and it works nevertheless.
How does my React-Client know which is the proper port? Does heroku routes all requests to port 5000? But how do they know? Do they scan the code?
I am asking, because I want to create a second WebSocket-Express server in the same index.js (is that possible?) file and redeploy that to heroku but think, without the use of different ports, that could not work.