Escaping the # character in .env file

一世执手 提交于 2021-02-05 09:23:29

问题


The secrete API key I want to store in my environment file for my express server is ignoring half of it as it contains a # symbol in the middle. I can't regenerate the key. And do not want it to be left unsequre


回答1:


i do not think it's because of the # symbol. It is only treated as signaling a comment when encountered as first chartacter in a line... you can try this yourself. create a .env file with the following content:

a=#b
c="#d"
#e=f

now run `node -e 'console.log(require("dotenv").config())'

this will return:

{ parsed: { a: '#b', c: '#d' } }

Is there maybe a newline character somewhere?



来源:https://stackoverflow.com/questions/60473515/escaping-the-character-in-env-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!