diff --git a/server.mjs b/server.mjs index e717c9f..5716382 100644 --- a/server.mjs +++ b/server.mjs @@ -137,6 +137,16 @@ async function toWebRequest(req, url) { } async function sendFromHandler(req, res) { + // TanStack server functions POST to /_serverFn/; a POST carrying the + // React server-actions header anywhere else is a probe (bots love + // `Next-Action: x`). Left alone it ties up an SSR stream until the 120s + // lifetime timer force-cleans it and Sentry reports a fatal uncaught + // exception — so reject it before the handler ever sees it. + if (req.headers["next-action"] !== undefined) { + res.writeHead(404, { "content-type": "text/plain" }); + res.end("not found"); + return; + } const url = `http://${req.headers.host ?? `${HOST}:${PORT}`}${req.url}`; const request = await toWebRequest(req, url); const response = await handler.fetch(request);