Appwrite + React: 跨源请求被阻止

huangapple go评论93阅读模式
英文:

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和端点来初始化您的客户端:参考链接

请确保尝试所有建议,并告诉我是否遇到任何问题 Appwrite + React: 跨源请求被阻止

英文:

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 is subdomain.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 Appwrite + React: 跨源请求被阻止

huangapple
  • 本文由 发表于 2023年6月12日 14:58:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76454243.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定