I am using react and have ran into a problem that I was having early but fixed. I got this working without any errors or CORS erros:
getProfile()
.then(profile => {
user = profile;
return generateToken();
})
.then(token => {
this.setState({
token
});
const headers = { Authorization: `Bearer ${token}` };
return axios.get(`https://taustin.auth0.com/api/v2/users/${user.sub}`, {
headers
});
})
.then(res => {
this.setState({
profile: res.data
});
})
.catch(err => {
this.setState({
err: err.message
});
});
Yet when I make a patch request to the same api/v2/users/{id}
:
axios
.patch(
`https://taustin.auth0.com/api/vs/users/${this.state.profile.user_id}`,
{ user_metadata: this.state.items },
headers
)
I get a CORS error like so:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.