#CORS and Live Preview

4 messages · Page 1 of 1 (latest)

versed sky
#

When checking the console on the frontend I noticed this error:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:3001') does not match the recipient window's origin ('http://localhost:3000').

(payload = 3001, next = 3000)

Which seems like some sort of CORS issue with live preview? Any insights?

Also, referencing this example it seems like data is coming from useLivePreview at all times. Is this okay? Should there be a draft mode or some sort of conditional so that it isn't trying to subscribe outside of the admin?

GitHub

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS. - payloadcms/payload

earnest briarBOT
dense portal
#

Hi, yes, data should come from the live preview on your front end. You don't need a draft mode. You should also add your frontend address to the cors in your payload config. Something like cors: [http://localhost:3000]. I hope this helps

versed sky
#

Figured, but just wanted to make sure. Thanks @dense portal !