jakeFeldman / strapi-provider-upload-azure-storage

Strapi Provider Upload Azure Storage
MIT License
75 stars 42 forks source link

Unable to download assets from Strapi Admin UI #86

Closed dzmitry-kankalovich closed 8 months ago

dzmitry-kankalovich commented 8 months ago

Hey,

I went through all instructions and it worked well for uploading assets and displaying their thumbnails.

However, in Admin UI when I try to download asset, I see a CORS error. It seems like download is done client-side (unlike upload) and this requires CORS setup - unless your blob container is under the same domain as Strapi itself.

So to fix this you need to set your Azure Blob storage account with CORS rule to allow such action. Example for terraform:

resource "azurerm_storage_account" "strapi" {
  name                     = "strapi"   
  # ...
  blob_properties {    
        cors_rule {        
        allowed_headers = ["*"]
        allowed_methods = ["GET","HEAD"]
        allowed_origins = ["*"]
        exposed_headers = ["*"]
        max_age_in_seconds = 3600
        }
    }
}

Posting this issue for visibility if someone will be looking here for solution like myself.

jakeFeldman commented 8 months ago

Thanks for the post and solution. Hopefully this helps others in the future!