JavaScript
NOTE: The documentation below assumes either
FIXIE_URLorFIXIE_SOCKS_HOSTEnvironment Variables are set. If your application is deployed on either Heroku or Vercel via our official integration, these environments will be set for you. Otherwise, see the setup guide for the platform you are using in the Platforms section below for how to set them manually.
Fixie works with both the standard http and https modules and with higher-level http clients, including the popular axios library.
Using Axios
Using fetch
Using http
For those using Fixie Socks,the socks npm package provides an agent that can be used by the Node’s http and https libraries, as well as by popular higher-level libraries like request.
Connecting to MySQL
MySql2 connects via a SOCKS connection provided as the stream property. Because Fixie Socks terminates idle connections after 60 seconds of inactivity, we suggest using connection pooling (this is a best practice regardless) or manual error handling. The example below uses connection pooling:
Connecting to Postgres or Amazon Redshift
As with mysql, you can pass a custom stream to the node-postgres library. This will work both for connections to Postgres databases as well as to Amazon Redshift:
Connecting to MongoDB
Establishing an SSH connection
The SSH2 library can be used to establish an SSH connection and execute commands over Fixie Socks.
Related static IP guides
Platform-specific guides for giving your Node.js app a static outbound IP:
- Node.js on Heroku → API
- Node.js on Vercel → Postgres
- Node.js on AWS Lambda → API
- Node.js on Render → MongoDB
- Node.js on Fly.io → Postgres
- Node.js on Heroku → SFTP
See the full list of static IP guides for every supported language, platform, and destination.
Is this guide useful?
Having issues? Please reach out to our team here.