typescript - Why can't angular2/http set header during development on webpack? -


setting header works when build project's war via gradle , deploy tomcat, reason, when spin webpack's development server testing, error:

exception: syntaxerror: failed execute 'setrequestheader' on  'xmlhttprequest': 'bearer xxx.yyy.zzz' not valid http header field value. in [null] (browser_adapter.ts:73). 

the frustrating thing has been intermittent. first had jwt 'xxx.yyy' , worked. of sudden didn't. realized might need include fake signature. changed 'xxx.yyy.zzz' , worked! of sudden didn't. thought maybe fake signature still had appropriate length rest of jwt. increased length, , worked. doesn't.

here's dev-proxy-settings.js:

module.exports = {     settings: {         '/*': {             target: 'http://localhost:3000/',             headers: {                 "access-control-allow-origin": "*",                 "access-control-allow-methods": "get, post",                 "access-control-allow-headers": "content-type, authorization"             }         }     } }; 

here's use of angular2/http

import {headers, http, requestmethod} 'angular2/http'; import {requestoptions, response} 'angular2/http';  ...  var headers = new headers({     'content-type': 'application/json',     'authorization': 'bearer xxx.yyy.zzz' }); var options = new requestoptions({     headers: headers,     method: requestmethod.get,     url: '/some/url' }); let httpresponse = this.http.request(options.url, options).map(...); 

am missing something??

the fake signature added had invalid character. i'm not sure character wasn't allowed, fake signature used blablablafakesignatureblablablanotrealblabl. changing eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee fixed it.

i added description of allowed headers webpack config file's devserver configuration. not sure if helped too, i'm not seeing error anymore.

devserver: {     port: metadata.port,     host: metadata.host,     // contentbase: 'src/',     historyapifallback: true,     watchoptions: { aggregatetimeout: 300, poll: 1000 },     headers: {         "access-control-allow-origin": "*",         "access-control-allow-methods": "get, post",         "access-control-allow-headers": "content-type, authorization"     },     proxy: proxysettings.settings },