I’m using Gridsome and included a Firestore plugin to source data from.
When using the Netlify environment variables my private key doesn’t work out because it includes many line breaks (/n in the .json file).
Is there a way to avoid this issue in the Netlify UI?
perry
February 6, 2020, 5:52pm
2
hi there,
I’m not 100% sure about this, but it could also be related to this limitation:
I believe the limitation in question is an AWS limitation (Environment properties and other software settings - AWS Elastic Beanstalk search for “4,096”) - around all environment variables, when first concatenated like this:
VARNAME1=val1,VARNAME2=val2
and creating a string, which must be <4096 characters including commas, possibly after encoding. So a very long string like that will likely cause that kind of breakage, considering that all build variables are taken together and our own variab…
is this applicable to your situation?
I don’t believe so…
I ended up added quotes around the entire variable in Netlify and then doing a JSON.parse(process.env.private_key)
1 Like
fool
February 8, 2020, 1:32am
4
Bit late to the party, but the way I’ve escaped in the past is shown here: [Support Guide] Using an SSH key via environment variable during build
Environment variables with embedded carriage returns are pretty hard for the shell, so a pattern like this is preferred even outside of the netlify build shell
Thanks @fool
The parsing of the string is working fine for me at the moment so I think I’ll just keep it like that unless I run into any issues and refer back to your solution.
1 Like
Thanks all. In JS, doing string substitution also seemed to work:
process.env.PRIVATE_KEY.replace(/\\n/gm, "\n")
2 Likes