'how to set socket server port in react app in heroku

I have deployed my react app to Heroku and also the socket server. Heroku assigns a different port every time than how I can set it in react app.

ex. for localhost: im setting socket server post 8900 and in react app, im using - socket.current = io("ws://localhost:8900");



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source