Search code examples
node.jsreactjsnext.jsaws-api-gatewayaws-amplify

"TypeError: handler is not a function" error in Amplify deployed app but it works locally


I have an app built in Nexjs (13.4, Node 18.16) that calls a Lambda function (API Gateway).

I have the same versions locally, and it runs fine when I do npm run dev, but I hit an error when I try to launch the website through the Amplify link.

Cloudwatch shows this error:

TypeError: handler is not a function
at Server.<anonymous> (/tmp/app/server.js:29:11)
at Server.emit (node:events:513:28)
at parserOnIncoming (node:_http_server:998:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)

Any idea? Thanks

I'm new to this technology so it might be something simple but I don't find anything online.

The deployment was already problematic (AWS compatibility issues with Node 18.16), I use a public image as the initial container public.ecr.aws/docker/library/node:18.16.0

Anyway, I tried with an out of the box nextjs app (default app) and I hit the same issue, which is disturbing.


Solution

  • I have the same problem with nextjs 13.4. I downgraded to 13.3 and it solved the problem and page renders fine. It seems like amplify is not fully ready for 13.4