{"record":{"id":"e3ea4a9e25804ae2","repo":"vercel/next.js","slug":"api-handler-should-not-return-a-value-received","errorCode":null,"errorMessage":"API handler should not return a value, received ${typeof apiRouteResult}.","messagePattern":"API handler should not return a value, received (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/api-utils/node/api-resolver.ts","lineNumber":445,"sourceCode":"\n    const resolver = interopDefault(resolverModule)\n    let wasPiped = false\n\n    if (process.env.NODE_ENV !== 'production') {\n      // listen for pipe event and don't show resolve warning\n      res.once('pipe', () => (wasPiped = true))\n    }\n\n    const apiRouteResult = await resolver(req, res)\n\n    if (process.env.NODE_ENV !== 'production') {\n      if (typeof apiRouteResult !== 'undefined') {\n        if (apiRouteResult instanceof Response) {\n          throw new Error(\n            'API route returned a Response object in the Node.js runtime, this is not supported. Please use `runtime: \"edge\"` instead: https://nextjs.org/docs/api-routes/edge-api-routes'\n          )\n        }\n        console.warn(\n          `API handler should not return a value, received ${typeof apiRouteResult}.`\n        )\n      }\n\n      if (!externalResolver && !isResSent(res) && !wasPiped) {\n        console.warn(\n          `API resolved without sending a response for ${req.url}, this may result in stalled requests.`\n        )\n      }\n    }\n  } catch (err) {\n    await onError?.(\n      err,\n      {\n        method: req.method || 'GET',\n        headers: req.headers,\n        path: req.url || '/',\n      },","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/api-utils/node/api-resolver.ts#L427-L463","documentation":"apiResolver warns (dev only) when an API route handler returns a non-undefined value; API routes must communicate via the res object, so a return value signals a misunderstanding (returning a Response throws outright in the Node runtime) and the value is otherwise ignored.","triggerScenarios":"Thrown at packages/next/src/server/api-utils/node/api-resolver.ts:445 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not return a value from the API handler; end the response with `res.status(...).json(...)` or `res.end()`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}