FormDexSecure form operations
Try FormDex
FormDexSecure form operations

A product by MeshDex

FormDex is a secure form operations platform for collecting, validating, and routing website submissions. Manage protected endpoints, email notifications, webhook delivery, and submission history from one reliable workspace.

Product

PlatformPricingDocumentation

Access

LoginRegisterReset password

Legal

Privacy PolicyTerms of ServiceRefund PolicyContact Us
  1. Home
  2. Documentation
  3. Integration
  4. Connect a Node.js or Express server
Docs home

Integration guide

Connect a Node.js or Express server

Keep the FormDex API key server-side, validate incoming data, forward trusted fields, and preserve upstream status codes.

Step by step

1

Render the browser trap

Put the visually hidden honeypot text input in the client form using the exact FormDex setting name.

2

Keep secrets server-side

Read the endpoint and API key from environment variables. Never send the FormDex key to the browser or include it in logs.

3

Reject bots before forwarding

If req.body.company contains any value, return a generic success response or a controlled rejection according to your abuse policy; do not call FormDex.

4

Forward an allowlist

Construct a new payload from approved keys instead of spreading req.body. Include the honeypot key as an empty string after it passes your local check.

5

Preserve upstream meaning

Return FormDex’s status and safe response body so the frontend can distinguish validation, authentication, credit, and rate-limit failures.

6

Set operational limits

Use a request timeout, avoid blind retries, and never record secrets or full message bodies in logs.

Honeypot in this integration

Where it belongs and who validates it

For a browser → Node.js → FormDex flow, the browser must render the honeypot and Node.js must reject any non-empty value before forwarding. After that local check, forward the same key as an empty string so the FormDex contract remains explicit. A server-only job does not benefit from a visual honeypot.

Read the honeypot fundamentals →

Working example

Browser form plus Express route

<!-- Browser: the honeypot must exist where bots can discover it. -->
<form method="POST" action="/contact">
  <div aria-hidden="true" style="position:absolute;left:-10000px;width:1px;height:1px;overflow:hidden;">
  <label>Leave this field empty
    <input type="text" name="company" tabindex="-1" autocomplete="off" />
  </label>
</div>
  <input type="email" name="email" required />
  <textarea name="message" required></textarea>
  <button type="submit">Send enquiry</button>
</form>

// Server: parse URL-encoded form bodies before this route.
app.post("/contact", async (req, res) => {
  // HONEYPOT: reject locally; never forward a bot submission.
  if (String(req.body.company || "").trim()) {
    return res.status(400).json({ error: "Spam detected." });
  }

  const payload = {
    email: String(req.body.email || ""),
    message: String(req.body.message || ""),
    company: "" // Must match the FormDex honeypot field name.
  };

  try {
    const response = await fetch(process.env.FORMDEX_ENDPOINT, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-Key": process.env.FORMDEX_API_KEY,
        "Origin": process.env.FORMDEX_ALLOWED_ORIGIN
      },
      body: JSON.stringify(payload),
      signal: AbortSignal.timeout(10_000)
    });
    const result = await response.json();
    return res.status(response.status).json(result);
  } catch {
    return res.status(502).json({ error: "Form service temporarily unavailable." });
  }
});

Troubleshooting

401 Invalid API key

Verify the environment variable on the running server and restart safely after changing it.

Timeout or 502

Use a bounded timeout and show a retry option without discarding the visitor’s input.

Unknown fields

Forward only schema keys or enable Dynamic fields intentionally.

Duplicate notifications

Do not retry accepted requests and avoid sending both directly from the browser and through the server.

Before you start

  • • Node.js with built-in fetch support or an equivalent HTTP client
  • • FORMDEX_ENDPOINT and FORMDEX_API_KEY stored as server environment variables
  • • JSON body parsing and request-size limits configured
  • • A browser form containing the visually hidden honeypot input

Production notes

  • • Set FORMDEX_ALLOWED_ORIGIN to the exact HTTPS origin configured for this form; do not copy an arbitrary incoming Origin header.
  • • The browser renders the trap, Node.js enforces it, and FormDex receives the verified empty field. This layered flow keeps the API key server-side.
  • • Never automatically retry a submission unless you have idempotency and duplicate-delivery handling.
View the complete integration overview →