Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Live Preview and CSRF

default discord avatar
asura_ks9 months ago
3

Hi all,



I'm trying to get Live Preview running with 2 different domains, both hosted on Azure.


Everything is working fine

but requests on collections that need authentication

.



I think the issue might be coming from the fact that these requests don't have any cookies in their headers.



Here's my setup:


- PayloadCMS running on Azure Web App


- Nuxt app running on Azure Web app


- Cors/Csrf configured in payload.config.ts


- Cors configured on Azure Web App CORS


- Latest version of PayloadCMS and Nuxt


- Using latest version of @payload/live-preview



Hope you can help me ^^

  • default discord avatar
    arimepareto_6654010 months ago

    I have a similar issue with the exception that I'm working on Google infrastructure: the application that implements live preview runs on Firebase and Payload on Cloud Run (different domains). I've tried to follow the instructions on setting up CORS and CSRF closely and everything run smoothly locally, but when I deploy the apps and try to use live preview for my collection, I'm getting response 403 from Payload when fetching relationships. I'm suspecting this is some sort of cookie sharing issue between sites (see attached screenshot), but I don't know how to solve it.



    Can live preview even work if Payload and the preview app run in two completely different domains?



    I found out that I can edit cookie options in my Users collection like so:



    const Users: CollectionConfig = {
      slug: "users",
      auth: {
        useAPIKey: true,
        cookies: {
          secure: true,
          sameSite: "none",
        },
      },
      ...


    This seemed to fix the issue for me, hope this helps someone else too!

  • default discord avatar
    notchr10 months ago

    TY for posting your solution



    Let us know if you run into any more issues

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.