We use a custom NextJS server to standardise logging, tracing and metrics in production. This uses NX's official support for .
Setup in new project
Follow these steps to configure our custom NextJS server in your NextJS project:
Add a server.ts file to the root folder of your NextJS project with the following content. Be sure to replace the {{variables}} with correct values. See apps/web/server.ts for example setup.
Finally, open the project.json file in your project folder and replace the "build" and "serve" target keys with the following content. Remember to replace the {{variables}} with correct values, and edit the build configurations as needed.