reactjscordovadotnetify

modifying dotnetify react js to use in cordova application (change path of dotnetify.react.connect)


I am using React app that wraps DotNetify around Cordova to build iOS and Android app.

Dotnetify connects to a WebSocket Server at given URL, we need to define based on build web or Cordova what is the host URL to connect to the Socket/SignalR server, current line is:

dotnetify.react.connect('Login', this);

the definition of Login is actually relative and I need to pre-pend the host URL somehow to tell build where is the WebSocket to connect to.

My assumption is it should be defined somewhere in Package.json to make it look like below:

dotnetify.react.connect('WSS://DEV.DOMAIN.COM/'+'Login', this);

What's the best solution to address this issue for development/debug mode locally or development on a server with public static IP or production server.

I have found base_url that needs to be passed in info object: node_modules/socksjs-client/lib/main.js:183

// allow server to override url used for the actual transport
  this._transUrl = info.base_url ? info.base_url : this.url;

So based on above I tried to pass argument, but donetify is not passing this argument to the socksjs. how do we fix this actually?

this.vm = dotnetify.react.connect('Login', this, {"base_url":"wss://dev.domain.com"});

Solution

  • You can use below to set below in your index.js to set the host right before connecting line.

    dotnetify.hubServerUrl = 'domain.example.com';