'Invalid character in header content ["authorization"] when sending bearer authorization request from thunder client

server.js

i tried to send an bearer token through thunder-client visual-studio code extension but got an error Invalid character in header content ["authorization"]

but it working fine with postman

const express = require('express')
const app = express()

app.use(express.json())
app.use(express.urlencoded({extended: true}))

app.get('/',(req,res)=>{
    res.status(200).send("welcome to the main page")
})
app.post('/',(req,res)=>{
    

     const bearerHeader = req.headers['authorization']
   
    if(typeof bearerHeader !== 'undefined'){
        
        console.log(req.headers)
        console.log(bearerHeader)
        res.send(req)
    }else{
        res.status(403)
   }
    
    //bearer.header.split('')
})


app.listen(8000,()=>console.log("server is running"))

package.json

{
  "name": "simple express app",
  "version": "1.0.0",
  "description": "",
  "main": "source.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^10.0.0",
    "ejs": "^3.1.6",
    "express": "^4.17.1",
    "helmet": "^4.6.0",
    "mongoose": "^6.0.7",
    "morgan": "^1.10.0",
    "nodemon": "^2.0.12"
  }
}

the error is shown in this picture

picture 2

can anyone help me on this thanks in advance



Solution 1:[1]

The issue is with the typo in the extension.

Please replace Content-type with content-type.

This issue occurs because the "C" is capital in the headers.

Solution 2:[2]

I managed to create a new line in the Authorization field by going down with the arrow key.

Solution: Delete the whole content until enter token palceholder is not visible and type it agin.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krushnasinh Jadeja
Solution 2 Zoltán Buzás