DEV Community

Discussion on: How to Store a Long, Multi-line Private Key in an Environment Variable

Collapse
 
nanythery profile image
Nadine M. Thêry • Edited

Hi! old thread here, but in case it helps, this solution worked for me for entering our Google Cloud Credentials in our Next Js project, but with the following adjustments:

  • The multiline key should be an actual valid JSON, otherwise it will fail just like happend to @inezabonte. To solve this I manually added all the breaklines with \n at the end of all the lines (including the last one). And created a long string with them. Just in case, use a JSON validator to be sure that your key is properly formatted.

Thank you @cfofiu for the main approach to this.