strapi / strapi-starter-next-corporate

Next.js starter for creating a corporate site with Strapi.
https://strapi-starter-next-corporate.vercel.app
MIT License
346 stars 94 forks source link

Error when deploying the front-end app to Vercel #37

Open taha-me opened 3 years ago

taha-me commented 3 years ago

Hi there,

when I deploy to Vercel, I got these errors: 14:22:34.674 Error occurred prerendering page "/en". Read more: https://nextjs.org/docs/messages/prerender-error
14:22:34.674 TypeError: Cannot read property 'text' of null
14:22:34.674 at /vercel/path0/.next/server/pages/[[...slug]].js:3147:36
14:22:34.674 at Array.map (<anonymous>)
14:22:34.674 at FeatureRowsGroup (/vercel/path0/.next/server/pages/[[...slug]].js:3126:29)
14:22:34.674 at d (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:498)
14:22:34.674 at bb (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:16)
14:22:34.674 at a.b.render (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:43)
14:22:34.674 at a.b.read (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
14:22:34.674 at exports.renderToString (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
14:22:34.674 at Object.renderPage (/vercel/path0/node_modules/next/dist/next-server/server/render.js:54:854)
14:22:34.674 at Function.getInitialProps (/vercel/path0/.next/server/pages/_document.js:761:19)
14:22:35.200 info - Generating static pages (4/8)
14:22:35.216 Not Found
14:22:35.217 Error occurred prerendering page "/fr/[[...slug]]". Read more: https://nextjs.org/docs/messages/prerender-error
14:22:35.217 Error: An error occured please try again
14:22:35.217 at fetchAPI (/vercel/path0/.next/server/pages/_app.js:574:11)
14:22:35.217 at processTicksAndRejections (internal/process/task_queues.js:93:5)
14:22:35.217 at async getGlobalData (/vercel/path0/.next/server/pages/_app.js:601:18)
14:22:35.217 at async Function.module.exports.1TCz.MyApp.getInitialProps (/vercel/path0/.next/server/pages/_app.js:299:24)
14:22:35.217 at async loadGetInitialProps (/vercel/path0/node_modules/next/dist/next-server/lib/utils.js:5:91)
14:22:35.217 at async renderToHTML (/vercel/path0/node_modules/next/dist/next-server/server/render.js:28:1494)
14:22:35.217 at async /vercel/path0/node_modules/next/dist/export/worker.js:26:6
14:22:35.217 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:5:584)
14:22:35.241 info - Generating static pages (6/8)
14:22:35.746 Not Found
14:22:35.747 Error occurred prerendering page "/fr/500". Read more: https://nextjs.org/docs/messages/prerender-error
14:22:35.747 Error: An error occured please try again
14:22:35.747 at fetchAPI (/vercel/path0/.next/server/pages/_app.js:574:11)
14:22:35.747 at processTicksAndRejections (internal/process/task_queues.js:93:5)
14:22:35.747 at async getGlobalData (/vercel/path0/.next/server/pages/_app.js:601:18)
14:22:35.747 at async Function.module.exports.1TCz.MyApp.getInitialProps (/vercel/path0/.next/server/pages/_app.js:299:24)
14:22:35.747 at async loadGetInitialProps (/vercel/path0/node_modules/next/dist/next-server/lib/utils.js:5:91)
14:22:35.747 at async renderToHTML (/vercel/path0/node_modules/next/dist/next-server/server/render.js:28:1494)
14:22:35.747 at async /vercel/path0/node_modules/next/dist/export/worker.js:26:6
14:22:35.747 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:5:584)
14:22:35.760 info - Generating static pages (8/8)
14:22:35.763 > Build error occurred
14:22:35.763 Error: Export encountered errors on following paths:
14:22:35.763 /en
14:22:35.763 /fr/500
14:22:35.763 /fr/[[...slug]]
14:22:35.763 at /vercel/path0/node_modules/next/dist/export/index.js:31:1106
14:22:35.763 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:5:584)
14:22:35.763 at async /vercel/path0/node_modules/next/dist/build/index.js:43:49
14:22:35.764 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:5:584)
14:22:35.764 at async /vercel/path0/node_modules/next/dist/build/index.js:25:1475
14:22:35.764 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:5:584)
14:22:35.807 error Command failed with exit code 1.
14:22:35.807 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
14:22:35.824 Error: Command "yarn run build" exited with 1

Please let me know what is the issue here, thanks

gregflint commented 3 years ago

npm run build produces the same error as well.

taha-me commented 3 years ago

So, I found the reason for the first issue here... when adding a new row to feature-rows-group on the home page of the Strapi backend, there should a value in the "text" field.

If not, Strapi will send "null" and Vercel app will break at the build process.

The solution is that Strapi backend should make this field mandatory, or adjust Next.js app to deal with empty "text" field.

remidej commented 3 years ago

Hey @taha-me, do you think the field that should be required would be this one?