Problem deploying project (prisma, crud, nextjs, netlify)

43 views Asked by At

The site works fine in localhost, but get errors during Build.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

I already installed and added "postinstall": "prisma generate" to script and installed @netlify/plugin-nextjs .

1

There are 1 answers

2
fool On

Looks to me like you are perhaps trying to use the prisma server to create content during the build; however, if the prisma server is something that you are deploying on Netlify, it won't be up and running at any accessible URL until after the build is complete. Bit of a chicken and egg problem if I am understanding it correctly.

If you are querying it at build time (not runtime/browse time, after the end of the deploy), I'd guess you either need to start it explicitly so you can query it (and then end it explicitly when the build is done) or use an external URL which is always available. You can host the prisma "server" on Netlify in a lambda, with a 2-step deploy process:

  • first, deploy prisma in a function including the prisma generate on site A
  • once that deploy succeeds, use a Build Hook to trigger a build on site B to pick up the new content. Note that you may want to turn off automatic builds on this second site so you don't get a useless build with your commit that changes the prisma content, before the server has the new data available to serve. You can do this as described in this article - which is something you have to ask their Support team to configure, but they are happy to do so.