DocumentationMumbai
Quickstart
Node.js 18 / 20 / 22Containerized Compute

Deploying Node.js API Backends

Host robust Express, Fastify, NestJS, or raw Node.js HTTP servers on Exovon Compute in Mumbai (asia-south1). Benefit from automatic HTTPS, DDoS mitigation, horizontal autoscaling, and zero-configuration containerization.

Zero Dockerfile Needed

Exovon detects your package.json start script and synthesizes a high-performance, hardened Linux container automatically.

Auto Scale-to-Zero

Idle APIs hibernate after 15 minutes of inactivity to save compute quotas, waking back up in sub-250ms when new traffic arrives.

Automated Health Probes

Edge routing canary probes verify HTTP 200 responses before shifting live traffic, ensuring zero broken releases.

1. Production Express / Fastify Server Template

To deploy successfully, your server MUST bind to the port provided by process.env.PORT (defaulting to 8080) and listen on the universal host address "0.0.0.0":

const express = require('express');
const app = express();
// 1. Parse JSON body payloads
app.use(express.json());
// 2. Health check endpoint (Required for Exovon canary verification)
app.get('/health', (req, res) => {
  res.status(200).json({ status: 'healthy', timestamp: Date.now() });
});
// 3. API route
app.get('/api/v1/data', (req, res) => {
  res.json({ message: 'Hello from Exovon Compute Mumbai!' });
});
// 4. CRITICAL: Bind to PORT on 0.0.0.0 (NOT 127.0.0.1)
const PORT = process.env.PORT || 8080;
const HOST = '0.0.0.0';
const server = app.listen(PORT, HOST, () => {
  console.log(`Server running on http://${HOST}:${PORT}`);
});
// 5. Graceful shutdown handler
process.on('SIGTERM', () => {
  console.log('SIGTERM received, closing HTTP server gracefully...');
  server.close(() => process.exit(0));
});
Important Host Warning: Never bind your server to 127.0.0.1 or localhost. Inside a Docker/gVisor container, 127.0.0.1 only listens to internal loopback traffic, preventing Exovon's reverse proxy from reaching your server and resulting in a 502 Bad Gateway error.

2. Package.json Configuration

Ensure your package.json defines a valid "start" script. If using TypeScript, include a "build" script that compiles to a dist folder:

{
  "name": "my-api-server",
  "version": "1.0.0",
  "main": "dist/index.js",
  "scripts": {
    "build": "tsc",
    "start": "node dist/index.js"
  },
  "engines": {
    "node": ">=18.0.0"
  }
}

3. Deploy via Exovon CLI

Deploy your API server straight from your local terminal:

# 1. Authenticate with your Exovon account:
npx exovon login
# 2. Link directory to your Exovon project:
npx exovon link --project my-api-server
# 3. Add production environment variables securely:
npx exovon env add JWT_SECRET "$(openssl rand -hex 32)"
# 4. Deploy containerized Node.js API to Mumbai edge:
npx exovon deploy --dynamic

Frequently Asked Questions

Can I deploy WebSocket servers with Node.js on Exovon?

Yes. Exovon Compute supports persistent WebSocket connections with HTTP Upgrade headers, allowing you to run Socket.io, ws, and real-time multiplayer servers.

How do I install native C++ npm packages like sharp or bcrypt?

Exovon build instances run on Debian Linux with standard build-essential and python3 toolchains pre-installed, ensuring node-gyp native compilation succeeds seamlessly.

Was this documentation page helpful?