[英]Error while get a blob from Azure storage (HTTP request) [VueJs]
I am trying to check if the blob with the path that I have exists in the Azure storage container or not. 我正在尝试检查Azure存储容器中是否存在具有路径的Blob。
this is my request: 这是我的要求:
let current_user_img = "https://XXXX.blob.core.windows.net/avatar/" + Img_name + ".png";
const instance = axios.create({
timeout: 3000,
headers: {
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods": "GET,POST,PUT",
"Access-Control-Allow-Headers": "x-ms-*,content-*",
"content-type": "application/json",
}
});
instance .get( current_user_img )
.then(function(response) {
console.log("User have an avatar.");
console.log(response);
})
.catch(function(error) {
console.log("User doesn't have an avatar.");
console.log(error);
});
And the CORS for my storage is as follows: 我的存储的CORS如下:
ALLOWED ORIGINS: '*'
ALLOWED METHODS: 'put,get,post'
ALLOWED HEADERS: '*'
EXPOSED HEADERS: '*'
MAX AGE: 0
when I try to run the code, I faced this error: 当我尝试运行代码时,遇到了以下错误:
Failed to load https://XXXX.blob.core.windows.net/avatar/XXXXXXXX.png: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
How can I solve it? 我该如何解决?
Try adding the withCredentials: true
prop to your request: 尝试将withCredentials: true
添加到您的请求中:
const instance = axios.create({
withCredentials: true,
timeout: 3000,
headers: {
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods": "GET,POST,PUT",
"Access-Control-Allow-Headers": "x-ms-*,content-*",
"content-type": "application/json",
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.