英文:
Appwrite + React :Cross-Origin Request Blocked
问题
尝试从Appwrite获取数据,但出现了CORS错误。
跨源请求被阻止:同源策略禁止读取远程资源 https://cloud.appwrite.io.v1/databases/{databaseId}/collections/{collectionId}/documents。 (原因:CORS请求未成功)。状态代码:(null)
如何在React或Appwrite仪表板中解决此问题?
英文:
Am trying pull data from appwrite but am getting CORs error.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io.v1/databases/{databaseId}/collections/{collectionId}/documents. (Reason: CORS request did not succeed). Status code: (null)
how do i resolve this in react or appwrite dashboard
答案1
得分: 2
跟Appwrite一起工作时出现CORS错误可能是由多种原因引起的。以下是您可以尝试的一些方法,看看是否有任何方法有效:
- 确保您已将客户端应用程序添加为appwrite仪表板中的平台。
- 确保主机名在平台中正确设置。如果您的客户端应用程序托管在
https://subdomain.example.com
上,您应该使用的主机名是subdomain.example.com
。 - 确保您使用正确的项目ID和端点来初始化您的客户端:参考链接
请确保尝试所有建议,并告诉我是否遇到任何问题
英文:
CORS errors when working with Appwrite can be caused by a number of reasons. Here's a list of things that you can try, and see if any of them works:
- Make sure you have added your client-side app as a platform in the appwrite dashboard.
- Make sure that the Hostname is set correctly in the platform. If your client-side app is hosted on
https://subdomain.example.com
, the hostname you should use issubdomain.example.com
. - Make sure you're initializing your client with the correct Project ID, and endpoint: reference
Make sure you try all the suggestions, and let me know if you face any issues
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论