I got this error firebaseapperror: failed to parse private key: error: invalid pem formatted message
when I pushed my nodejs app to heroku.
I had my environment variables all set like this
# .env file
project_id=project_id
private_key='-----BEGIN PRIVATE KEY----- ... ------END PRIVATE KEY-----\n'
client_email=client_email
And accessed them like so:
export const sa = {
privateKey: process.env.private_key,
projectId: process.env.project_id,
clientEmail: process.env.client_email
};
On my local everything worked fine, but on production (heroku) I got the error mentioned above. The private key is a multiline environment variable and it couldn't be parsed.
Please, how do I fix this?