I decided to go all in with Netlify on a Next.js project I’m working on. So, I’ve got Netlify identity, Netlify functions, and I’m even using Fauna.
I gotta say that
Netlify Dev works like a charm. Nice work!
Now here’s the deal…
The site uses dynamic routing, so I can use a URL like this
https://mysite/things/thing-slug and display a page specifically for that
slug. This is thanks to
getStaticProps from Next.js.
As I will potentially have a lot of things, and new things may be created between builds, I’m using
fallback: true in
This all works swimmingly on my local running the app both with
netlify dev and
npm run build && npm run start, which is the equivalent
next build followed by
next start. In the latter scenario, I run the Netlify functions with
Now there’s one thing that doesn’t work, but it only doesn’t work in production.
Once the site is deployed to production, and a new
thing is added (to the db), attempting to access the slug page, https://mysite/things/new-thing-slug/ results in an error:
GET https://mysite.netlify.app/_next/data/eDkYkRXXhrj8JP46OysaH/things/new-thing-slug.json?slug=new-thing-slug 500
While it’s entirely possible that I’m doing something wrong, this is strange because this works with a manual build (
next-build) running with
next start, locally, which should be as close to production as I can get.
I’m guessing this is something happening under the hood with how Netlify serves Next.js apps, but I can’t seem to get any info from the logs. And I have updated the nextjs plugin to the latest (@firstname.lastname@example.org).
I’m going to try to deploy this on another platform to test, but in the meanwhile it would be great if anyone’s come across this before and might have an idea of why this is happening and how I might resolve it.