Nexmo’s Node.js Server SDK Added Support for Host Overriding

Published January 17, 2020 by Alex Lakatos

We’ve recently released v2.6.0 of our Node.js SDK and added the ability to change the host used for making the HTTP requests.

Why?

This feature allows you to override the default hosts, api.nexmo.com and rest.nexmo.com, in the SDK. One of the most common uses cases for this feature is bypassing the load balancer, and making the HTTP requests towards one of our location-specific Data Centres, for example, api-sg-1.nexmo.com.

Let’s take a look at our “Make an outbound call with an NCCO” Code Snippet and change it to use the Singapore Data Centre when making the phone call.

Looking closely, the only change we made to the code snippet was adding an options object in the Nexmo instance, with an apiHost property.

Another common use case for this feature is using a proxy or gateway to inspect your requests before they get passed on to the Nexmo API. Let’s use curlhub to inspect all our API traffic.

After you sign up, curlhub gives you a Bucket Id. For example, n43s3qc13thd. That gets appended to any host you want to proxy. So if we want to proxy api.nexmo.com, the corresponding curlhub host is api-nexmo-com-n43s3qc13thd.curlhub.io. The same logic applies for rest.nexmo.com, and the corresponding curlhub host is rest-nexmo-com-n43s3qc13thd.curlhub.io.

In order to use those as the proxies for the requests our SDK makes, we’ll have to add the apiHost and restHost properties to our new Nexmo instance.

What’s Next

We’re working on improving our Node.js SDK, and you can track our progress at https://github.com/nexmo/nexmo-node. If you have any suggestions or issues, please feel free to raise them in GitHub or in our community slack.

Leave a Reply

Your email address will not be published.