'Socket IO Remote Websocket URL is getting flipped to LocalHost in development

I am working with Socket IO. Yesterday I changed my development tool from Windows to MacOS to continue development.

I have the following code that is working well by opening a Websocket connection to a remote URL as follows:

const socketUrl = "https://api.someapiendpoint.com";
let socketOptions = {transports: ["websocket"]}
let socket;
if (!socket) {
    socket = io(socketUrl, socketOptions);
}

This is all working well on my Windows Machine. However, on my Mac I noticed that socket io is force switching the url back to localhost. This is weird.

As a result I currently cannot test socket io on my Mac.

Any ideas to resolve this would be truly appreciated.

Please note that I am on node

14.19.1


Sources

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

Source: Stack Overflow

Solution Source