CORS issue? #395
-
I've tried adding a domain to the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
The Could you share what you you have in your Payload config for CSRF? Perhaps you're setting it as a string and not in a an array? I'm happy to look if you have more info to share, thanks! |
Beta Was this translation helpful? Give feedback.
-
UPDATE: I misread the docs / am a CORS noob and this is not needed, see the correct reply below!
|
Beta Was this translation helpful? Give feedback.
-
I added cors to Payload config but when cross origin request if made, payload is returning html string in the response's body instead of a json file. How do I deal with that? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, I’m facing a CORS issue with my Payload CMS backend in production. My frontend (https://www.example.com) makes a POST request to the backend (https://api.example.com), but it’s blocked with this error:
What I tried is to configure cors in buildConfig and it worked with GET methods only.
Works in development (localhost), but fails in production for POST requests. Any idea why it happens exactly with POST? Any idea how to solve it? |
Beta Was this translation helpful? Give feedback.
The
Access-Control-Allow-Origin
header should be included automatically in the API after you have added it to your config.Could you share what you you have in your Payload config for CSRF? Perhaps you're setting it as a string and not in a an array?
Could it be that you're using an env variable that isn't available with your deployment?
I'm happy to look if you have more info to share, thanks!