Skip to content

Live preview not longer working #14033

Closed
Closed

Description

@philippkdhl

Describe the Bug

I use @payloadcms/live-preview version 3.58.0 in my Angular app.

Unfortunately, in Payload version 3.58.0, no window event is received in my Angular app anymore. However, it still works in Payload version 3.54.0.

What could be the reason for this?

this.subscription = subscribe({ initialData: {}, serverURL: 'http://localhost:3000', callback: () => { console.log('get new dara from cms'); } });

Link to the code that reproduces this issue

Reproduction Steps

Work on Version 3.54.0 -> working

Upgrade to 3.58.0 -> not working

Which area(s) are affected? (Select all that apply)

Not sure

Environment Info

    "@payloadcms/admin-bar": "3.58.0",
    "@payloadcms/db-mongodb": "3.58.0",
    "@payloadcms/live-preview-react": "3.58.0",
    "@payloadcms/next": "3.58.0",
    "@payloadcms/payload-cloud": "3.58.0",
    "@payloadcms/plugin-form-builder": "3.58.0",
    "@payloadcms/plugin-nested-docs": "3.58.0",
    "@payloadcms/plugin-redirects": "3.58.0",
    "@payloadcms/plugin-search": "3.58.0",
    "@payloadcms/plugin-seo": "3.58.0",
    "@payloadcms/richtext-lexical": "3.58.0",
    "@payloadcms/translations": "^3.58.0",
    "@payloadcms/ui": "3.58.0",

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Oct 2, 2025
  2. removed
    validate-reproduction
    on Oct 2, 2025
  3. github-actions commented on Oct 2, 2025

    @github-actions
    Contributor

    Please add a reproduction in order for us to be able to investigate.

    Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.

    Why was this issue marked with the invalid-reproduction label?

    To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with create-payload-app@latest -t blank or a forked/branched version of this repository with tests added (more info in the reproduction-guide).

    To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

    Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.

    I added a link, why was it still marked?

    Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

    Useful Resources

  4. orhancelik1 commented on Oct 7, 2025

    @orhancelik1

    I have the same issue. It is working in 3.54.0 but not working in 3.58.0

  5. orhancelik1 commented on Oct 30, 2025

    @orhancelik1

    I fixed it with updating all packages same version including "@payloadcms/live-preview-react"

  6. philippkdhl commented on Oct 31, 2025

    @philippkdhl
    Author

    Unfortunately not in my case.

    I think the bug comes with this PR: #13631

  7. philippkdhl commented on Oct 31, 2025

    @philippkdhl
    Author
    Image

    this is not working since 3.58.0 or 3.57.0

  8. paulpopus commented on Oct 31, 2025

    @paulpopus
    Member

    Are you able to provide a reproduction for us please? We have quite a few test suites using live preview so it is working in most setups still

    I've also noticed in your package list that translations are "@payloadcms/translations": "^3.58.0", you should pin the version here to ensure it doesn't ever deviate from the rest of the packages

  9. philippkdhl commented on Oct 31, 2025

    @philippkdhl
    Author

    What exactly do you need from me? Should I provide a sample project with the CMS and an Angular app?

  10. philippkdhl commented on Nov 3, 2025

    @philippkdhl
    Author

    @paulpopus Should I provide a sample project with the CMS and an Angular app?

  11. paulpopus commented on Nov 3, 2025

    @paulpopus
    Member

    @philippkdhl yes please, just a minimum reproduction needed that we can run to see what the issue might be

  12. self-assigned this
    on Nov 3, 2025
  13. removed
    status: needs-triage
    on Nov 3, 2025
  14. philippkdhl commented on Nov 3, 2025

    @philippkdhl
    Author

    cms.zip

    Hi @paulpopus, i have created an example for you. It is an Angular app that goes to a static route in the CMS in CmsService. You will need to adapt this yourself.

  15. paulpopus commented on Nov 3, 2025

    @paulpopus
    Member

    @philippkdhl Could you put this up on a public github repo please? For security we can't really open random zips from the internet

  16. paulpopus commented on Nov 3, 2025

    @paulpopus
    Member

    Yes I can, thank you @philippkdhl

  17. jhb-dev commented on Nov 13, 2025

    @jhb-dev
    Contributor

    I can also reproduce this issue with the latest Payload versions. The PostMessage event with type payload-document-event is not sent to the page in the iframe anymore.

  18. paulpopus commented on Nov 18, 2025

    @paulpopus
    Member

    Hey everyone, so I pulled down the repo and live preview works as expected for me following the docs here https://payloadcms.com/docs/live-preview/client#building-your-own-hook

    The part that you were missing is telling the admin panel that your frontend is ready to receive the messages by adding this after the subscribe

    // add ready import
    import { ready } from "@payloadcms/live-preview";
    
    // in onNgInit
    ready({ serverURL: environment.twoMhCms });

    Also when fetching data since we utilise draft data for live preview so your data fetching should instead be with draft=true in the case of live preview being enabled.

    Some extra tips for setting this up in a performant way, I'm not sure about Angular equivalents but in Nextjs we have draftMode() as an API that allows us to toggle drafts dynamically without breaking our static site and you may need to do something similar - we have this behind authentication as well just to be clear so only admins can actually enter this draft mode.

    Then based on that cookie, header or param however you wish to do it, you would enable drafts in your data fetching. Our website template, uses this pattern.

    To further help you with data fetching you can also try using the API SDK if it makes some APIs easier.

  19. philippkdhl commented on Nov 19, 2025

    @philippkdhl
    Author

    Perfect! Thank you for this hint :)

    It works now!

  20. github-actions commented on Nov 27, 2025

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  21. locked as resolved and limited conversation to collaborators on Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions