milliHQ / terraform-aws-next-js

Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.
https://registry.terraform.io/modules/milliHQ/next-js/aws
Apache License 2.0
1.47k stars 151 forks source link

[BUG] Decorators in API and Runtime Node 16.x.x support #355

Open MastalerzKamil opened 2 years ago

MastalerzKamil commented 2 years ago

Summary In my Next app I'm using Next.js API decorators library. It works locally in production command yarn build and then yarn start. I'm working on Node version 16.15.1. After deployment through tf-next there is with not finding routes properly. E.g. I have routes GET /healthand GET /health/test in the same file under path pages/api/health/[[...params]].ts. The lambda sees only /healthwithout /health/test. I would like to add that locally it works both on development command and production command?

Environment Node: 16.15.11 TypeScript: 4.7.4 Next: latest

My investigation I think that the problem could be with experimental decorators or lambda environment. I've tried to change it manually but still problem exists. I thought that the problem could be on library site but somehow if I run it locally with production build, everything works as expected.

Quesstions

  1. Is there any way to choose lambda versions with node 16.x.x before deployment?
  2. What could be the reason that it works locally and it doesn't on lambda after (hopefully) also using command next build?