Using Inspectr with Express
Inspectr is a great tool for debugging and analyzing API traffic in Node.js applications, including those built with Express. You can use it to inspect incoming requests to your Express app by placing Inspectr as a proxy in front of it.
Use Inspectr as a Proxy
Section titled “Use Inspectr as a Proxy”Inspectr sits in front of your app and captures traffic before forwarding it to your Express backend.
1. Start Your Express App
Section titled “1. Start Your Express App”Make sure your app is running, for example on port 3000:
const express = require('express');const app = express();
app.use(express.json());
app.post('/api/data', (req, res) => { console.log('Received:', req.body); res.status(200).json({ message: 'OK' });});
app.listen(3000, () => console.log('Server running on port 3000'));
2. Start Inspectr in Front of Your App
Section titled “2. Start Inspectr in Front of Your App”inspectr --listen=:8080 --backend=http://localhost:3000
Now, make requests to http://localhost:8080/api/data
. Inspectr will:
- Log the request in the terminal
- Show it in the Inspectr App UI
- Forward it to your Express app on port 3000
Optional: Expose Your Express API Publicly
Section titled “Optional: Expose Your Express API Publicly”You can expose your local Express server with Inspectr Ingress:
inspectr \ --listen=:8080 \ --backend=http://localhost:3000 \ --expose \ --channel=express-demo \ --channel-code=express123
Your public endpoint will be:
https://express-demo.in-spectr.dev
Summary
Section titled “Summary”Inspectr enhances Express development by giving you full visibility into all traffic and making debugging simple and interactive. While middleware-based capture is not supported, proxy mode works great for local and public exposure workflows.