Node.js HTTP - TypeError: The header content contains invalid characters

Straight up, looks like we need to use:

 headers: {
    'content-type': 'application/json',
  },

instead of

 headers: {
    'Content-Type': 'application/json',
  },

these types of vague error messages make me sad!


I had a similar issue where I was generating a jwt token for Authorization and it was inserting newline characters. Replacing those with token.replace(/\r?\n|\r/g, '') did the trick for me.


That's not why. It's because your dash ‐ is not the standard dash:

> /-/.test('cloudsso‐test.myco.com')
false

> /‐/.test('cloudsso‐test.myco.com')
true