My client side look like this :
$http(
{
method: 'GET',
url: myConfig.serverUrl + '/getUserId',
data: '',
headers: { 'Authorization' : '21321313'},
});
Server side in Node js and express :
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, content-type, Authorization');
next();
});
But request not set the Authorization value
OPTIONS /getUserId HTTP/1.1.
Host: xxxxx.
Connection: keep-alive.
Pragma: no-cache.
Cache-Control: no-cache.
Access-Control-Request-Method: GET.
Origin: http://localhost:9000.
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36.
Access-Control-Request-Headers: authorization.
Accept: */*.
Referer: http://localhost:9000/.
Accept-Encoding: gzip, deflate, sdch.
Accept-Language: en-US,en;q=0.8,he;q=0.6.
I have try many ways but none of them work.
When i try to to that with postman i get the value so i think my problem in my angular side but i cant figure out what is the problem .