0

I am trying to check if the blob with the path that I have exists in the Azure storage container or not.

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:

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?

1 Answer 1

1

Try adding the withCredentials: true prop to your request:

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",
   }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.