jsonwebtoken error
Description
If you encounter error below:
Uncaught Error: error:0909006C:PEM routines:get_name:no start line
Reason
Bad format private key value. In the jsonwebtoken node package, the sign() function.
Example,
jsonwebtoken.sign(PAYLOAD, PRIVATE_KEY, OPTIONS)
the PRIVATE_KEY value above must be string, and sometimes this string can be mistakenly "JSON.stringify()". Even though the end result is still a string, but JSON.stringify encoding turns the string into JSON string format, and it's not a value we want to provide to the sign() function.
Below is example error code
//error from node_modules/jsonwebtoken/sign.js
{
library: 'PEM routines',
function: 'get_name',
reason: 'no start line',
code: 'ERR_OSSL_PEM_NO_START_LINE'
}