next-drupal
next-drupal copied to clipboard
Next site breaks if I'm logged in in Drupal, with preview mode active
I have configured the preview site, everything is working, I'm able to see the Next site on the iframe in Drupal.
But if I login in Drupal I get a 500 error on the iframe, and if I try to open the Next site in a new window I get the same 500 error.
The problem is on the __next_preview_data cookie, if I remove it, I can see the Next site again.
This only happens if I'm loggedIn in Drupal
this is my exit-preview.tsx
import { NextApiResponse } from "next";
export default function exit(_, response: NextApiResponse) {
response.clearPreviewData();
response.writeHead(307, { Location: "/" });
response.end();
}
and preview.tsx
import { NextApiRequest } from "next";
import { drupal } from "@/lib/drupal";
export default async function handler(request: NextApiRequest, response: any) {
return await drupal.preview(request, response);
}
I've the same problem Next-Drupal 1.6 Next.js 13 drupal 9
Same here, Internal Error 500 in the same situation
I'm looking into this.
Which version are you on for Next.js? 13.x.x?
13.3.0 but the bug was present even on 12
Which node version are you using ? Do you have some logs when the internal error is occuring ? I had the same errors, but it was with the password policy (password expired) on the Next.js user.
--
We're getting other 500's errors (502, 503, 504) here, on AWS ECS (.25 vCPU / 1GB Ram). The Next.js container is killed and an another container is up. But we've 0 (application) error or log, it's just turn off.
To display an 500 error, we're refreshing a content in preview mode, and a content in Next.js site (sometime, multiples time), and the container crashes.
Next.js v13.2.1 (same issue with Next.js 12.x version) Node.js v18.16 (same issue with Node 16.x version) Drupal 9.5 (same issue with Drupal 10)
@shadcn I'm UP if you need more information and/or test.
v 16
Hello, the preview mode seems to be deprecated, in favor of Draft Mode, on Next.js (https://nextjs.org/docs/pages/building-your-application/configuring/preview-mode). Maybe a clue?
Mine has been fine until i updated to 13.4.1, oddly though I don't get the issue on my local version only when it's deployed
Same issue here.
I have a Drupal backend https://admin.xxxx.xx I have a NextJS frontend https://xxxx.xx
As an administrator, If I preview the node /node/example, my preview is broken, I get a 500 error on the iframe. On the same browser, If I go to the NextJs app, on the page /node/example, my page is broken, I get a 500 error. On the NextJs app tab, if I delete the cookie "__prerender_bypass", my page is back to normal.
This issues happened as soon as we moved from http to https on both Drupal and NextJs sides.
This error never occurs when I'm not connected to Drupal (ie: the cookie doesn't exist).
EDIT: If I'm doing the same test locally, without HTTPS, everything is working.
Regards,
EDIT2: We finally made it. We added in the preview.ts file:
forceIframeSameSiteCookie: process.env.NODE_ENV === "development",
And removed in the src/pages/[...slug].tsx
if (preview) {
const previewBannerContainer = document.getElementById("preview-banner");
const Test = () => <Alert color="error">You are in preview mode</Alert>;
previewBannerContainer ? createPortal(<Test />, previewBannerContainer) : <></>;
}
Is there any update on this issue? If there's no immediate plans to fix it I'll attempt to do a PR if I get time.
I am facing the same issue here. I am running multilanguage configuration and only main language is affected thought.
I think this may have been an issue in nextjs, just installed the latest version and not getting the error anymore