Reputation: 179
I am developing some web-page that allows to upload files from client side to my azure storage directly. My files are stored on Azure BLOB Storage in Portal. For this I am using 'azure-storage' v2.8.1 package from npm.
While I am trying to create container:
const blobService = AzureStorage.createBlobServiceWithSas(storageUri, sasToken)
blobService.createContainerIfNotExists(containerName, { publicAccessLevel: 'blob' }, (error, result, response) => {.....})
I got errors:
OPTIONS [url to my storage] 403 (CORS not enabled or no matching rule found for this request.)
Failed to load [url to my storage]: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am sure that blob connection string is correct - I checked it. In addition I know that I can edit CORS for my storage on azure.portal. Currently it is empty.
Should I need to add/edit there some CORS? Do someone know solution?
Upvotes: 5
Views: 9514
Reputation: 24569
Should I need to add/edit there some CORS? Do someone know solution?
Yes, you need to add the CORS setting for storage blob service. By default, CORS is disabled for each service. We could get more information about CORS from this article.
Note: CORS is not supported for Premium Storage accounts.
We also could set it from Azure portal. More details please refer to the screenshot.
Upvotes: 9