many answers talk about vue or react but i wanna know how can i solve cors in vanilla.
var config = {
method: 'put',
mode: 'no-cors',
url: 'http://192.168.0.53/api/v2.0.0/status',
headers: {
'Authorization': 'Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'http://127.0.0.1:5501',
'Access-Control-Allow-Methods': 'POST, GET, PUT, DELETE, OPTIONS',
},
credentials: 'same-origin',
crossdomain: true,
data: data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
i’ve treid most solution i’ve seen but doesn’t work…