{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular-cli/issues/3253","repository_url":"https://api.github.com/repos/angular/angular-cli","labels_url":"https://api.github.com/repos/angular/angular-cli/issues/3253/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular-cli/issues/3253/comments","events_url":"https://api.github.com/repos/angular/angular-cli/issues/3253/events","html_url":"https://github.com/angular/angular-cli/issues/3253","id":191327509,"number":3253,"title":"Chrome is giving the Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Authorization: Bearer ' is not a valid HTTP header field name ","user":{"login":"JavaCoder12","id":21183106,"avatar_url":"https://avatars.githubusercontent.com/u/21183106?v=3","gravatar_id":"","url":"https://api.github.com/users/JavaCoder12","html_url":"https://github.com/JavaCoder12","followers_url":"https://api.github.com/users/JavaCoder12/followers","following_url":"https://api.github.com/users/JavaCoder12/following{/other_user}","gists_url":"https://api.github.com/users/JavaCoder12/gists{/gist_id}","starred_url":"https://api.github.com/users/JavaCoder12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JavaCoder12/subscriptions","organizations_url":"https://api.github.com/users/JavaCoder12/orgs","repos_url":"https://api.github.com/users/JavaCoder12/repos","events_url":"https://api.github.com/users/JavaCoder12/events{/privacy}","received_events_url":"https://api.github.com/users/JavaCoder12/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-23T16:54:20Z","updated_at":"2016-11-23T23:09:36Z","closed_at":null,"body":"> Please provide us with the following information:\r\n> ---------------------------------------------------------------\r\n\r\n### OS?\r\n> Windows 7\r\n\r\n\r\n### Versions.\r\n> Please run `ng --version`. If there's nothing outputted, please run in a Terminal: `node --version` and paste the result here:\r\nangular-cli: 1.0.0-beta.20-4\r\nnode: 6.9.1\r\nos: win32 x64\r\n\r\n### Repro steps.\r\n> Was this an app that wasn't created using the CLI? What change did you do on your code? etc. I have created the app with CLI \r\n![capture](https://cloud.githubusercontent.com/assets/21183106/20570923/88d9360a-b173-11e6-92d3-0d18c2b16a13.JPG)\r\n\r\nEnvironments – Angular2 with CLI + Boot Strap4 is Front End ( localhost:4200)\r\nSpring boot + Security +JWT + REST Ful Controllers for Back End (localhost:8080)\r\n\r\nChrome is giving the Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Authorization: Bearer ' is not a valid HTTP header field name the same piece of code is working fine with IE.\r\n\r\nI have been breaking my head from last two weeks and did lot of googling and unable to resolve the issue. As I am running out of time I am posting this question here hoping some Angular2 Gods will provide suggestions to resolve this issue.\r\n\r\nEnvironments – Angular2 with CLI + Boot Strap4 is Front End ( localhost:4200)\r\nSpring boot + Security +JWT + REST Ful Controllers for Back End (localhost:8080)\r\n\r\nHere is the scenario:\r\n \r\nLogin Screen \r\n \r\n Onsubmit - Passing the Credentials to the Spring Boot Security to Authenticate.\r\n \r\n onSubmit() {\r\n     \r\n     this.loginService.authenticateUser(this.loginUserDtls)\r\n     .subscribe( \r\n\t  data => {\r\n\t\tlet token=  JSON.parse(JSON.stringify(data))._body;\r\n        console.log(\"TOKEN  VALUE \"+token) ;\r\n   \t\tthis.loginService.sendToken(token).subscribe( \r\n        data => {\r\n\t\t\tlet dataRet=  JSON.parse(JSON.stringify(data))._body;\r\n\t\t\tconsole.log(\"data received  \"+dataRet);\r\n         }\r\n        )\r\n        \r\n     });\r\n On Successful authentication Spring Security generating the JWT Token   and sending the token back to fort end keeping it in the response header as below \r\n \r\n  response.addHeader(\"Authorization\", \"Bearer \" + JWT);\r\n  \r\n Issue 1- \r\n Some reason Angular 2 (localhost:4200) response header is missing the Authorization header details   which is placed in the Spring Boot Security Services (localhost:8080)\r\n\r\nFor Issue 1- I had a workaround by sending the JWT token in the response body. \r\n\r\nAfter extracting the token the from response body, I am invoking a different restful service by passing token in the Angular 2 request Header as below :\r\n\r\nsendToken(token)  {\r\n\r\n    var headers = new Headers();\r\n    headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\r\n    headers.append('Authorization', 'Bearer '+ token);\r\n    headers.append('Accept', 'application/json');\r\n\r\n    return this.http.get('http://localhost:8082/users', {headers:headers});\r\n     \r\n }\r\n \r\nThe above worked is working fine in IE but when testing the same thing in Chrome getting  the \r\n Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Authorization: Bearer ' is not a valid HTTP header field name. Also please verify the screenshot for more detailed console log.\r\n \r\n I had tried the above code with RequestOptions withCredentials = true also but no luck with Chrome.\r\n \r\n Please kindly post your suggestions to resolve the issue.\r\n\r\n\r\n### The log given by the failure.\r\n> Normally this include a stack trace and some more information.\r\n\r\n\r\n### Mention any other details that might be useful.\r\n\r\n> ---------------------------------------------------------------\r\n> Thanks! We'll be in touch soon.\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular-cli/issues/comments/262652158","html_url":"https://github.com/angular/angular-cli/issues/3253#issuecomment-262652158","issue_url":"https://api.github.com/repos/angular/angular-cli/issues/3253","id":262652158,"user":{"login":"JavaCoder12","id":21183106,"avatar_url":"https://avatars.githubusercontent.com/u/21183106?v=3","gravatar_id":"","url":"https://api.github.com/users/JavaCoder12","html_url":"https://github.com/JavaCoder12","followers_url":"https://api.github.com/users/JavaCoder12/followers","following_url":"https://api.github.com/users/JavaCoder12/following{/other_user}","gists_url":"https://api.github.com/users/JavaCoder12/gists{/gist_id}","starred_url":"https://api.github.com/users/JavaCoder12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JavaCoder12/subscriptions","organizations_url":"https://api.github.com/users/JavaCoder12/orgs","repos_url":"https://api.github.com/users/JavaCoder12/repos","events_url":"https://api.github.com/users/JavaCoder12/events{/privacy}","received_events_url":"https://api.github.com/users/JavaCoder12/received_events","type":"User","site_admin":false},"created_at":"2016-11-23T23:09:36Z","updated_at":"2016-11-23T23:09:36Z","body":"Hi Clydin, I have verified JWT Token it has only ASCII Characters. \r\n\r\nBelow is the key -  eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInNjb3BlcyI6IkFETUlOIiwiaXNzIjoiVEVTVCIsImlhdCI6MTQ3OTk0MjI5MCwiZXhwIjoxNDc5OTQyMzUwfQ.oBhh90hvqRBvOWQR5UY5dP-0V22o0fRjt0dhrDi3g7OBycN1qwnsmZvnjwQcqz0O_bLbo9mLLNn5fUmJ8ctwog\r\n![capture](https://cloud.githubusercontent.com/assets/21183106/20581572/dfd2668c-b1a7-11e6-9679-f26f17befa03.JPG)\r\n\r\nAttached is the screenshot with Key token. Please kindly let me know if you have any other suggestions.\r\n\r\n\r\n"}}
{"actor":{"display_login":"JavaCoder12"}}