I have a preview.js file in my api/pages folder which calls
res.setPreviewData({});
res.end();
This works in development (starting the server with the "next" command and open up 'api/preview' in a browser), I get a Set-Cookie header from the server, and the browser successfully stores the cookie and context.preview is true in getStaticProps().
However, when I make a production build (next build && next start), the browser will not save the cookie. My api/preview route still returns a Set-Cookie header, though.
Am I misunderstanding how this is supposed to work? This could seem to have nothing to do with Next.js, considering that the headers are set correctly. Any ideas on what might cause this?
I expected the cookies to be set exactly like in development mode.
If applicable, add screenshots to help explain your problem.
Production mode requires your application be served from a secure connection! Otherwise, the cookies will not be set. Please try this behind a HTTPS proxy or on Vercel!
Most helpful comment
Production mode requires your application be served from a secure connection! Otherwise, the cookies will not be set. Please try this behind a HTTPS proxy or on Vercel!