I am trying to send the request from one localhost port to the another. I am using angularjs on the frontend and node on the backend.
Since it is CORS request, In node.js, i am using
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
and in the angular.js service file, I am using
return {
getValues: $resource(endpoint + '/admin/getvalues', null, {
'get': {
method: 'GET',
headers:{'Authorization':'Bearer'+' '+ $localStorage.token}
}
}),
}
I am getting the following error
Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
Please help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…