supabase-community / partner-gallery-example

Supabase Partner Gallery Example
https://supabase.com/partners
MIT License
112 stars 31 forks source link

Build Error Prerendering Page for Partner generated Route #6

Closed starmorph closed 1 year ago

starmorph commented 1 year ago

I am getting an error while building my app on vercel and locally. on vercel it says this:

Error occurred prerendering page "/partners/testdd". Read more: https://nextjs.org/docs/messages/prerender-error

08:49:51.869 | TypeError: Cannot read properties of null (reading 'map') 08:49:51.869 | at Partner (/vercel/path1/.next/server/pages/partners/[slug].js:174:62) 08:49:51.870 | at d (/vercel/path1/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:498) 08:49:51.870 | at bb (/vercel/path1/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:16) 08:49:51.870 | at b.render (/vercel/path1/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:43) 08:49:51.870 | at b.read (/vercel/path1/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83) 08:49:51.870 | at exports.renderToString (/vercel/path1/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138) 08:49:51.870 | at Object.renderPage (/vercel/path1/node_modules/next/dist/server/render.js:680:46) 08:49:51.871 | at Object.defaultGetInitialProps (/vercel/path1/node_modules/next/dist/server/render.js:350:67) 08:49:51.871 | at Document.getInitialProps (/vercel/path1/.next/server/pages/_document.js:29:20) 08:49:51.871 | at Object. (/vercel/path1/node_modules/next/dist/shared/lib/utils.js:75:33)

Build error occurred

08:49:52.061 | info - Generating static pages (7/7) 08:49:52.064 | Error: Export encountered errors on following paths: 08:49:52.065 | /partners/[slug]: /partners/test 08:49:52.065 | /partners/[slug]: /partners/testdd 08:49:52.065 | at /vercel/path1/node_modules/next/dist/export/index.js:404:19 08:49:52.065 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 08:49:52.066 | at async Span.traceAsyncFn (/vercel/path1/node_modules/next/dist/trace/trace.js:79:20) 08:49:52.066 | at async /vercel/path1/node_modules/next/dist/build/index.js:1230:21 08:49:52.066 | at async Span.traceAsyncFn (/vercel/path1/node_modules/next/dist/trace/trace.js:79:20) 08:49:52.066 | at async /vercel/path1/node_modules/next/dist/build/index.js:1092:17 08:49:52.067 | at async Span.traceAsyncFn (/vercel/path1/node_modules/next/dist/trace/trace.js:79:20) 08:49:52.067 | at async Object.build [as default] (/vercel/path1/node_modules/next/dist/build/index.js:65:29)

Locally it says this: 2023-01-20T15:39:03.276Z Failed to compile. 2023-01-20T15:39:03.276Z
2023-01-20T15:39:03.277Z ./pages/partners/integrations/index.tsx:40:3 2023-01-20T15:39:03.277Z Type error: Expression expected. 2023-01-20T15:39:03.277Z
2023-01-20T15:39:03.277Z 38 | const [partners, setPartners] = useState(initialPartners) 2023-01-20T15:39:03.277Z 39 | const [featured, setFeatured] = 2023-01-20T15:39:03.278Z > 40 | const allCategories = Array.from( 2023-01-20T15:39:03.278Z | ^ 2023-01-20T15:39:03.278Z 41 | new Set(initialPartners.map((p) => p.category)) 2023-01-20T15:39:03.278Z 42 | ) 2023-01-20T15:39:03.278Z 43 | 2023-01-20T15:39:03.325Z Error: Command "npm run build" exited with 1 2023-01-20T15:39:03.513Z

I am on a M1 Mac running OS Venture 13.1 I have configured my supabase environment variables locally and on vercel and have added 2 rows to the partner and partner contact supabase. This problem happens once a row is created in the partners table.

Thank you very much for the help I would love to get this app working

sleithdylan commented 1 year ago

Hi @starmorph,

I was having the exact same issue but after spending an hour at it I got it successfully building on both Vercel & Locally, this is how:

  1. Create a new Supabase project
  2. You will then need to run schema.sql in your SQL Editor in Supabase to create the tables.
  3. For your environment variables make sure they are the following when developing locally and for production on Vercel:
    SUPABASE_HOSTNAME="db.YOUR_DATABASE_HOST.supabase.co" 
    NEXT_PUBLIC_SUPABASE_URL="YOUR_API_URL"
    NEXT_PUBLIC_SUPABASE_ANON_KEY="YOUR_ANON_PROJECT_API_KEY"
  4. So this is what the issue seems to be. Since you are not passing an array of images to the images column it is causing an error, there are two things you can do:
    1. Add an array of image(s) into your database like so ["https://i.imgur.com/6vy29vC.png"] (Do this if you want images)
    2. In [slug].tsx, just remove the whole div for the Swiper altogether.

This solved the issue for me, let me know if it works for you :)

jaredlutz commented 1 year ago

Nice man, this worked for me