最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Response was blocked by CORB (Cross-Origin Read Blocking) : Appwrite + React - Stack Overflow

programmeradmin1浏览0评论

I am using appwrite as backend for a blog website. In it I am storing images and fetching them using their id to display. However the browser is showing CORS restriction due to which image is not getting loaded on the website.

Below code is how I am using the image

<img
src={appwriteService.getFilePreview(post.featuredImage)}
alt={post.title}
className="rounded-xl"
/>

Below code is the definition of getFilePreview function

getFilePreview(fileId){
 return this.bucket.getFilePreview(
   config.appwriteBucketId,
   fileId
 )
}

I am using appwrite as backend for a blog website. In it I am storing images and fetching them using their id to display. However the browser is showing CORS restriction due to which image is not getting loaded on the website.

Below code is how I am using the image

<img
src={appwriteService.getFilePreview(post.featuredImage)}
alt={post.title}
className="rounded-xl"
/>

Below code is the definition of getFilePreview function

getFilePreview(fileId){
 return this.bucket.getFilePreview(
   config.appwriteBucketId,
   fileId
 )
}
Share Improve this question asked Feb 16 at 11:26 Noobmaster69Noobmaster69 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

CORS errors usually happen because the project is missing a web platform that allows the app to connect to it. To add a web platform:

  1. Open your project in the Appwrite Console
  2. Scroll down to the Integrations section
  3. Click the Add platform button
  4. Select Web app
  5. Enter the hostname for your app

Besides the web platform, other reasons you may get this error are:

  1. lack of access due to permissions on the bucket or file
  2. incorrect project, bucket, or file id

Reference: https://appwrite.io/blog/post/cors-error

发布评论

评论列表(0)

  1. 暂无评论