Code:
function App() {
useEffect(() => {
axios({
url: 'http://____/user/list',
method: 'GET',
dataType: 'json',
headers: {
'Authorization': '______',
},
})
.then( res => {
console.log('| response |', res)
})
.catch( error => {
console.log('| error |', error);
})
}, [])
return (
<div></div>
)
}
Error:
Access to XMLHttpRequest at 'http://___' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I understand I am making an XMLHttpRequest to a different domain than my page is on and that Postman calls "POST" request directly but we send an "OPTIONS" request first. Is the browser or server blocking it for security reasons? Am I missing anything in the client side or server side?