Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping the # character in .env file

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

like image 605
Fardeen Khan Avatar asked Oct 28 '22 01:10

Fardeen Khan


1 Answers

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?

like image 158
Holger Will Avatar answered Nov 09 '22 08:11

Holger Will