I am using sprestlib to upload a file to sharepoint, for that I am getting Access to XMLHttpRequest "url" from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request. Authentication will be needed to use sharepoint endpoint. I am not sure which header to use ?
This is the code
sprLib.rest({
url:'sites/Documents/test',
type:"POST",
data:reader.result,
headers:{
headers:{
"accept": "application/json;odata=verbose",
"content-length": reader.result.byteLength,
"X-RequestDigest":<digest value>
}
}
})
.then(function(objFile){
console.log('SUCCESS: '+objFile.Name);
})
.catch(function(strErr){
console.error(strErr);
});
}