Posts tagged “Fastify”
Fastify logging: getting the most from the built-in pino logger
Fastify logs every request out of the box, but the default skips routes, user agents and bodies, and Fastify 4 trusts client request ids. A tested production config for Fastify 4 and 5.
Fastify monitoring: hooks, metrics and APM for Fastify 4 and 5
Set up Fastify monitoring that shows which route got slow and why: onResponse timings, fastify-metrics histograms, @fastify/otel spans per hook, and under-pressure load shedding, with output from real runs.
Node.js server timeouts: requestTimeout, headersTimeout and keepAliveTimeout
Random 502s behind a load balancer often come down to one setting: keepAliveTimeout. What each Node.js server timeout controls, safe values behind an AWS ALB, and how to confirm the fix.
401 vs 403 in your Node API logs: what each pattern means
401 and 403 look alike in a log but answer different questions. What each means under RFC 9110, four auth patterns worth an alert, how to return the right one in Express and Fastify, and five searches to run on last week's logs.
Block .env and config-file probes in Express and Fastify
One site logged 1,028 requests for credential paths in a day, including /.mcp.json and other AI tool configs. How to check none can succeed, return a fast 404 in Express and Fastify, and block the IPs doing it.
Node.js large file upload handling without running out of memory
One 2 GB upload should not take your API down with it. Here is how to stream uploads in Express and Fastify, when to use presigned URLs, and which parsers to patch.
Cursor vs offset pagination: an API design that survives big tables and scrapers
Offset pagination was fast at launch; now deep pages hammer the database and one API key is walking every page. Here is when to switch to cursors and how.
Your MCP server is an API. Debug it like one.
A remote MCP server works on localhost, then fails in production with a vague "tool call failed." Lost sessions behind a load balancer, expiring OAuth tokens and proxies that cut streams off are all visible at the HTTP layer. Here's where to look.
Zod validation in Express and Fastify: request bodies, query strings and useful errors
A null where your handler expected an array becomes a 500 and a support ticket. Validate bodies, query strings and params with Zod 4 in Express 5 and Fastify 5, return 400s clients can act on, and stop extra fields at the door.
CORS misconfiguration in Express and Fastify: how to find it and test for it
One line added to silence a frontend error, cors({ origin: true, credentials: true }), lets any website read your users' data. Find CORS misconfiguration in Express and Fastify APIs, fix it, and test it in CI.
Fastify hooks for logging and auth: onRequest, preHandler and onResponse explained
Auth checks that run before the body exists, log lines missing the status code, handlers that run after a 401: most come from using the wrong Fastify hook. Here is which hook does which job in Fastify v5, with working code.
BOLA vulnerability in Node APIs: how to fix IDOR and catch it in your logs
Change one digit in a URL and get another customer's invoice. Here is how to fix BOLA and IDOR structurally and spot someone probing for it before they find a gap.