I am trying to consume a login endpoint and I am getting the error in my console has been blocked by CORS policy.
here is my function that handles login
async function loginUser(credentials) {
return fetch('https://visbackend.herokuapp.com/auth/login', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
// 'Access-Control-Allow-Origin': '*',
// "Access-Control-Allow-Headers": "X-Requested-With"
// 'Access-Control-Allow-Origin': 'http://127.0.0.1:3000',
// 'Access-Control-Allow-Methods': 'POST',
// 'Access-Control-Allow-Headers': 'Content-Type, Authorization'
},
body: JSON.stringify(credentials)
})
.then(data => data.json())
}
i understand i am supposed to allow cors , but i have gone through every sample as you can see, i have some lines of code commented out , but the error still persists.
please what am i doing wrong, thanks in advance.