
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).
TypeScript
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.
TL;DR
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.Recommended threads
- How to reduce DB Reads?
I just noticed that I hit the 500k db reads limit on my very small next js app with the most data being present in one collection having around 50 documents. ...
- Getting issue while migrating from Self ...
i try to migrating my project but when do this error come and dont allow to crate that migration
- Pending upload some file, but not for ot...
When upload this file, always got pending. But when I upload another file, it works. Why?
