Long Environment Variable with line breaks (\n)

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?

hi there,

I’m not 100% sure about this, but it could also be related to this limitation:

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)

Bit late to the party, but the way I’ve escaped in the past is shown here: [Common Issue] 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 :slight_smile:

Thanks @fool :wink:

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