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 95 forks source link

Some fields are compulsory but not marked as such in Strapi #20

Closed maggie44 closed 3 years ago

maggie44 commented 3 years ago

I was getting the following error message:

`[ ==] info - Generating static pages (1/7) Error occurred prerendering page "/home". Read more: https://err.sh/next.js/prerender-error TypeError: Cannot read property 'mime' of null at /tmp/learners-block-website/frontend/.next/server/pages/[[...slug]].js:2487:20 at Array.map () at FeatureRowsGroup (/tmp/learners-block-website/frontend/.next/server/pages/[[...slug]].js:2468:20) at d (/tmp/learners-block-website/frontend/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:498) at $a (/tmp/learners-block-website/frontend/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:39:16) at a.b.render (/tmp/learners-block-website/frontend/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:476) at a.b.read (/tmp/learners-block-website/frontend/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:18) at renderToString (/tmp/learners-block-website/frontend/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:54:364) at Object.renderPage (/tmp/learners-block-website/frontend/node_modules/next/dist/next-server/server/render.js:50:851) at Function.getInitialProps (/tmp/learners-block-website/frontend/.next/server/pages/_document.js:305:19) info - Generating static pages (7/7)

Build error occurred Error: Export encountered errors on following paths: /home at exportApp (/tmp/learners-block-website/frontend/node_modules/next/dist/export/index.js:25:1103) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async build (/tmp/learners-block-website/frontend/node_modules/next/dist/build/index.js:37:212) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

Turns out there are a bunch of fields that are compulsory, but not set as such in Strapi. This one was cause by Media in a FeatureRowsGroup. I have encountered at least one more but not been able to reproduce it to identify which caused the issue.

I'm not familiar enough with the platform, but either making these fields compulsory in Strapi, or coding in some defaults to stop it erroring would be helpful.

joseananio commented 3 years ago

Hi, I'm getting a similar error with FeatureRowsGroup when a link is not provided. I assume the Link object is not compulsory?. I'll use the hero for now. It doesn't have such issues, but it would be nice to try this too.
Cheers

Server Error
TypeError: Cannot read property 'startsWith' of null
components/elements/custom-link.js (6:34) @ CustomLink

  4 | 
  5 | const CustomLink = ({ link, children }) => {
> 6 |   const isInternalLink = link.url.startsWith('/')
    |                                  ^
  7 | 
  8 |   // For internal links, use the Next.js Link component
  9 |   if (isInternalLink) {