MigsOriginal post
Apple Developer
So, the function works fine with Postman and returns the expected response. However, when called from localhost or a hosted origin it doesn't return any response, even though it executes normally (I see the changes in the console).
Access to XMLHttpRequest at 'https://671cc505e87cdf1dff9b.appwrite.global/' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Tried adding CORS headers in the returned responses and nothing changed. Also tried putting a wildcard * as a hostname for my platform.
Summary
Developers encountering CORS error when trying to call an Appwrite function from a different origin. Function works in Postman but not from localhost or a hosted origin due to missing 'Access-Control-Allow-Origin' header. Adding CORS headers to responses and using a wildcard hostname did not resolve the issue.
**Solution**: To fix the issue, developers need to add the 'Access-Control-Allow-Origin' header to the responses of the Appwrite function. This header should include the correct origin (e.g., 'http://localhost:5173') or '*' for all origins. This should allow the function to be called successfully from different origins.