I am testing the Robinhood API and the first thing I need to do is login using the API. I am able to login with the following code when I run node login.js
var axios = require('axios')
axios.post('https://api.robinhood.com/api-token-auth/', {
username: 'email@email.com',
password: '********'
}, {
headers: {'Access-Control-Allow-Origin': '*'}
}).then(function (response) {
console.log(response.data);
})
However, when I try the same code with React in a browser, I receive the No 'Access-Control-Allow-Origin'
error. If I enable Access-Control-Allow-Origin
in Chrome, the error does not occur and I can login.
I have already included the Access-Contrl-Allow-Origin
header. The problem seems to be a disparity between Node and React/Chrome?
What's allowing the code to run with Node but not with React/Chrome?