I have followed all of the steps here to the letter: Previews with Next.js - Prismic and cannot get the preview to work on local development or on the remove development environment. The troubleshooting sticky thread seems a little outdated, and honestly I'm completely stuck on how to troubleshoot further. I am using NextJS. Any help would be massively appreciated.
Mini update: I was able to get the previews to start working on localhost, but they still do not work on the server. I see now when I try to go to /api/exit-preview on the server, it shows a 404 in the console. When I try the same on localhost:3000/api/exit-preview, the preview is exited as expected. Is there something I'm missing on deploy? I'm deploying to Netlify with the build command:
npx next build && npx next export and out as my publish directory. Everything else seems to be working fine with this setup - content shows, hooks trigger, etc.
Another update: I found this thread from a while ago - Preview not working on netlify - #4 by fprovost where it looks like the api directory isn't supported by Netlify, which would explain my 404. But how do you convert the preview code to a Netlify function? This seems like something that should definitely be in Prismic's NextJS/Netlify deployment documentation steps. Again, help is appreciated here.