我正在try 将请求从一个本地主机端口发送到另一个本地主机端口.我用angularjs on the frontend and node on the backend.
因为它是CORS个请求,在 node 中.js,我在用
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');
在Angular 上.js服务文件,我正在使用
return {
getValues: $resource(endpoint + '/admin/getvalues', null, {
'get': {
method: 'GET',
headers:{'Authorization':'Bearer'+' '+ $localStorage.token}
}
}),
}
我得到以下错误
Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
请帮忙!