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


I just had the same problem,
Apparently Appwrite don't set automatically the header in the function response, maybe it's a bug
You are missing "Access-Control-Allow-Origin", in your Appwrite function to add it
And since this is horrible, I suggest
References: