Environment variables containing newlines in Node?

后端 未结 8 465
再見小時候
再見小時候 2021-02-02 06:00

I\'m attempting to load an RSA private key into my nodejs application using environment variables, but the newlines seem to be being auto-escaped.

For the following, ass

8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-02 06:31

    I was using:

    JSON.parse(`"${process.env.PUBPEM}"`)
    

    which suddenly started to fail. So I changed it to:

    JSON.parse(JSON.stringify(process.env.PUBPEM))
    

    Which solved it for me.

提交回复
热议问题