React / Firebase project. Trying to delete a document.
Error message: Access to XMLHttpRequest at ... from origin 'http://localhost:3000' has been blocked by CORS policy: Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response.
I've added Access-Control-Allow-Methods and Access-Control-Allow-Origin headers to try and fix it but there's no effect.
firebase
.auth()
.currentUser.getIdToken(true)
.then((token) => {
console.log(token)
return axios.delete(
`${FunctionsDir}/deleteMessage`,
{
messageID: messageID,
},
{
headers: {
Authorization: `Bearer ${token}`,
'content-type': 'application/octet-stream',
'Access-Control-Allow-Methods': 'DELETE',
'Access-Control-Allow-Origin': 'http://localhost:3000',
},
}
)
})