opennextjs-netlify: API route as Netlify function 502s

Describe the bug Plugin internal error when deploying a serverless Next.js app on Netlify. The error is: Error: No static assets found in .next dist (aka no /.next/static).

Full error message:

Plugin "@netlify/plugin-nextjs" internal error

Error: No static assets found in .next dist (aka no /.next/static). Please check your project configuration. Your next.config.js must be one of serverless or experimental-serverless-trace. Your build command should include next build.

In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
at copyNextAssets (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/src/lib/steps/copyNextAssets.js:14:11)
at async build (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/src/index.js:25:3)
at async nextOnNetlify (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/src/index.js:75:5)
at async onBuild (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js:67:5)
at async Object.run (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/run.js:18:3)
at async handleEvent (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/main.js:36:38)
at async process. (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/ipc.js:103:16)

To Reproduce I first did nothing but install the plugin from Netlify’s UI. Then it showed me an info message in the deployment logs that I should set the target property in next.config.js to be either serverless or experimental-serverless-trace. I set it to serverless. It then showed me the error posted above.

Link to the app: https://github.com/omarryhan/trendzz/ Link to the failed deployment: https://app.netlify.com/sites/trendzz/deploys/609b8568b7933100072efaad

Expected behavior Deploy without an error.

Versions

  • Next.js: ^10.2.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25

Commits related to this issue

Most upvoted comments

@omarryhan hahah i was sure it was something unique to your config but nope! hope you enjoyed my commit names 😄. such a random thing. if/when i figure out the res.end weirdness ill try to remember to report back here. thanks for your patience and help!!

omg it was in the original post hahaha sorry i need to sleep lmao. will look asap!!!

Sorry, not sure what this has to do with nx. Also, his build dir is set to "dist/apps/basic". Mine is the default, so it should work without manually changing the build dir.