datrix-agent is a local API proxy service for Datrix API Studio. It allows a browser app to trigger local HTTP requests (including localhost APIs) through a trusted local agent.
This package now ships as a TypeScript library plus CLI:
- CLI: run
datrix-agentglobally - Library: import helpers in Node.js projects with full
.d.tstypes
- Local server on
http://localhost:4590 - Health endpoint:
GET /health - Request execution endpoint:
POST /request - Supported methods:
GET,POST,PUT,PATCH,DELETE,OPTIONS - Streaming-safe response handling with 10MB cap
- 30-second request timeout
- CORS allowlist for approved web app origins
- Security host blocking for risky targets
npm install -g datrix-agentFor library usage in another project:
npm install datrix-agentnpm install
npm run buildBuild output is generated under dist/.
datrix-agentOptional flags:
datrix-agent --port 4590 --origins "http://localhost:3000,https://yourwebapp.com"When running, the agent prints:
- Datrix Local Agent running
- Port: 4590
- Ready to receive requests
import { createServer, resolveAllowedOrigins, executeRequest } from "datrix-agent";
const allowedOrigins = resolveAllowedOrigins("http://localhost:3000,https://yourwebapp.com");
createServer({ port: 4590, allowedOrigins });
const result = await executeRequest({
url: "http://localhost:5000/api/users",
method: "GET",
});
console.log(result.statusCode, result.body);GET /health
Response:
{
"status": "running"
}POST /request
Request body:
{
"url": "http://localhost:5000/api/users",
"method": "GET",
"headers": {
"Authorization": "Bearer token"
},
"body": {}
}Success response:
{
"status": 200,
"headers": {},
"data": {}
}fetch("http://localhost:4590/request", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
url: "http://localhost:5000/users",
method: "GET"
})
});Blocked hosts:
169.254.*0.0.0.0
Limits:
- Timeout: 30 seconds
- Max response size: 10MB
npm login
npm run build
npm pack
npm publishRecommended first publish checklist:
- Ensure package name availability:
npm view datrix-agent - Verify files being published:
npm pack --dry-run - Bump version before each release:
npm version patchfor fixesnpm version minorfor featuresnpm version majorfor breaking changes
- Publish with public access (first publish for scoped packages):
npm publish --access public