✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Troubleshooting NextJS Preview Functionality on Netlify and Vercel

4 replies
Last updated: May 16, 2020
Still struggling with the Preview Functionality in NextJS.
On localhost it works just fine, but when deployed to Netlify the /api/preview route displays a 404...
Any ideas?

I followed the Example:
May 15, 2020, 5:17 PM
I think netlify deploys are static- so that won’t work with NextJS previews. For NextJS previews you need a server. I haven’t tried myself but in this example it shows deploying to Vercel— have you tried that?
May 16, 2020, 4:12 AM
Thanks, that's sounds plausible (unfortunately). Wasn't really looking to switch away from Netlify, though... But I will check it out!
May 16, 2020, 9:27 AM
Nope, getting the same 404 on Vercel...Maybe
user Y
can you tell us real quick, wether this is an Vercel vs. Netlify issue or must be sth. else?
May 16, 2020, 10:01 AM
Okay, solved! The problem was with the build command.
I had
npm run build
, which was wrong.It needed to be
next build
Hope this helps somebody else! (Haven't tried on Netlify yet, but it's working for Vercel)
May 16, 2020, 10:10 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?