The firebase service-account JSON was downloaded and accessed via environment variable in NESTJS application on Local it works fine (using this steps https://dev.to/cfofiu/how-to-store-a-long-private-key-in-vercel-s-environment-variables-46f5)
however when I try to run the application on GCP cloud container using (environment variables or secret manager) I get the following error
Failed to parse private key: Error: Invalid PEM formatted message. Error: Failed to parse private key: Error: Invalid PEM formatted message.
Tried all the following possibilities but still having the same issue
- Access via secret manager by variable and replacing the
process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')
- Access via environment variable
- Access via secret manager/ environment variable and placing the entire JSON as string and parse it through JSON.parse
I have also tried many options however all the builds were failed with the same error. Is there any way from cloud run directly to access the firebase account to overcome the issue