Back

Another CORS Problem

  • 0
  • Functions
  • Web
olildu
25 Jan, 2024, 05:46

I am trying to send a post request to one of my functions and I always get an CORS Error `<script> const url = "https://sample.appwrite.global/"; const headers = { "Content-Type": "application/json" };

const data = { "key": "", "uid": "" };

fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(data) }) .then(response => response.text()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));

</script>`

This is the code on the client side πŸ‘†

I have attached the error screenshot as well as platform web app hostname

Any help would be much appreciated

TL;DR
Developers are facing a CORS error when sending a POST request to a function. They have provided the client-side code and an error screenshot. They request assistance in resolving the issue. Solution: Enable CORS on the server-side by adding the appropriate headers to the response.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more