i want to get data with post method from axios package and xampp sever, i have an error when work with firefox :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1/aftab/inventory3/v1/repository/all. (Reason: missing token ‘x-auth’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).[Learn More] Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1/aftab/inventory3/v1/repository/all. (Reason: CORS request did not succeed)
but when test it in chrome it work correctly and i don't have any error ,
my axios request code is:
let page = 1;
let config =
{
'Content-Type': 'application/x-www-form-urlencoded',
'x-auth': localStorage.getItem("token"),
};
let data = {page: page};
if (localStorage.getItem("token")) {
await axios({
method: "post",
url: "http://127.0.0.1/aftab/inventory3/v1/repository/all",
data: data,
headers: config
}).then(function (response) {
console.log(response);
}).catch(function (error) {
if (error.response) {
cosole.log(response);
} else if (error.request) {
console.log(error.request);
} else {
console.log('Error', error.message);
}
console.log(error.config);
});
} else {
localStorage.removeItem("token");
// this.history.push('/log/in');
}
in the firefox console :
in firefox console network, only option method was sent and after it we dont have any request but in the chrome it work correct and we have a post method request after option method