#Live preview update issue during production

2 messages · Page 1 of 1 (latest)

noble loom
#

I'm implementing live preview and in my main config I have

livePreview: {
      url: process.env.NEXT_PUBLIC_PAYLOAD_URL,
}

And in a collection/global I have

livePreview: {
      url: ({ locale }) => {
        const params = new URLSearchParams({
          path: `${locale}/`, // Or any other path
          secret: PAYLOAD_SECRET,
        })

        return `/draft?${params.toString()}`
      },
    }

While in dev mode it works just fine. The live preview shows and updates accordingly. However, when deploying in production mode I get the following error when clicking the preview button

Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.

Why is this happening if I'm setting the url in payload config?

warm vortexBOT