Issue with Next JS SSG preview mode and `next-i18next` package causing 500 error on Netlify
6 replies
Last updated: Dec 16, 2021
P
Hi,I’m getting
when in Preview Mode (Next JS SSG).
But actually, the live preview DOES work (Studio Pane and external window) – but only on localhost. As soon as I try in production I only ever get an Error 500…
Also, when I try to (unsuccessfully) access the Preview in production and the relevant Cookie(s) is/are set, it in turn leads to a 500 that persists, even when NOT in preview mode.
When I delete these Cookies, “Normal Mode” functions perfectly again…
Anyone experienced sth. similar or has any ideas why it would work just fine locally but not in production?
It’s a public dataset, I’ve checked all the relevant CORS settings and the environment variables are the same (if I didn’t miss anything). I tried hosting the frontend on Netlify and on Vercel – makes no difference.
Not authenticated - preview not available eval @ next-sanity.esm.js?c596:159
But actually, the live preview DOES work (Studio Pane and external window) – but only on localhost. As soon as I try in production I only ever get an Error 500…
Also, when I try to (unsuccessfully) access the Preview in production and the relevant Cookie(s) is/are set, it in turn leads to a 500 that persists, even when NOT in preview mode.
When I delete these Cookies, “Normal Mode” functions perfectly again…
Anyone experienced sth. similar or has any ideas why it would work just fine locally but not in production?
It’s a public dataset, I’ve checked all the relevant CORS settings and the environment variables are the same (if I didn’t miss anything). I tried hosting the frontend on Netlify and on Vercel – makes no difference.
Dec 15, 2021, 7:09 PM
P
Hi, here’s an overview 🙃
S = Sanity, N = NextJS, prod. = deployed / hosted on Netlify S (local) + N (local) = 🟢* // works perfectly, but "Not authenticated" from next-sanity.esm.js S (local) + N (prod.) = 🔴 // 500 Internal Server Error for N S (prod.) + N (local) = 🟠 // displays page, but doesn't apply changes live, no error 500, no "Not authenticated" error S (prod.) + N (prod.) = 🔴 // 500 Internal Server Error for N
Dec 16, 2021, 10:38 AM
P
Hi, here’s an overview 🙃
S = Sanity, N = NextJS, prod. = deployed / hosted on Netlify S (local) + N (local) = 🟢* // works perfectly, but "Not authenticated" from next-sanity.esm.js S (local) + N (prod.) = 🔴 // 500 Internal Server Error for N S (prod.) + N (local) = 🟠 // displays page, but doesn't apply changes live, no error 500, no "Not authenticated" error S (prod.) + N (prod.) = 🔴 // 500 Internal Server Error for N
Dec 16, 2021, 10:38 AM
P
Thanks, but please don’t bother :-) I “fixed” it just now. In the end it came down to the
next-i18nextpackage causing problems, but only in the specific combination of either SSR or SSG-in-preview-mode on Netlify (Vercel was fine either way). This lead to an error 500 that persisted as long as the cookie was set. I’ve since switched to the
next-translatepackage as I just couldn’t get
next-i18nextto work on Netlify.
Dec 16, 2021, 6:02 PM
P
Thanks, but please don’t bother :-) I “fixed” it just now. In the end it came down to the
next-i18nextcausing problems, but only in the specific combination of either SSR or SSG-in-preview-mode on Netlify (Vercel was fine either way). This lead to an error 500 that persisted as long as the cookie was set. I’ve since switched to the
next-translatepackage as I just couldn’t get
next-i18nextto work on Netlify.
Dec 16, 2021, 6:02 PM
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.