Nextjs Tips and Tricks

Image of Author
Invalid Date (last updated October 18, 2022)

Reading repository files

Files in your project repository can be read successfully. The tricky part is that relative paths work in dev, but will not work on prod. The fix is to use Nodejs APIs to convert your relative path to an absolute path. I am doing this via path.resolve, e.g., path.resolve(./local.json).

Facts and FYIs

  • Nextjs API Routes are hosted on AWS Lambas and are referred to as the "Nodejs runtime", which is distinct from the Edge runtime. I do not know where/how the edge runtime is hosted.