Assistance with storing Firebase JSON credentials for Node.js bot
Anonymous
FREEOP

15 days ago

Hello,

I'm deploying a Node.js bot that requires a Firebase Admin SDK credentials file (firebase-key.json). The bot reads this file directly with require('./firebase-key.json').

I tried storing the JSON content in an environment variable (FIREBASE_CONFIG_JSON) and using a build command (echo $FIREBASE_CONFIG_JSON > firebase-key.json) to create the file, but I keep getting JSON parsing errors (e.g., "No number after minus sign in JSON at position 1"). I suspect the issue is that the variable contains raw newlines (from the private key) that break the JSON format when written.

What is the recommended way to handle such credential files on Railway? Is there a "Secret Files" feature where I can upload the JSON file directly? If so, how do I access it? Alternatively, how can I properly store the JSON content in a variable so that it writes a valid JSON file (with \n escapes intact)?

I'm using the Railway CLI (railway up) for deployment. Any guidance would be greatly appreciated.

Thank you!

$10 Bounty

1 Replies

Railway
BOT

15 days ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway 15 days ago


Railway unfortunately doesn't support files as variables at the moment. However, what I would suggest is that you base64 encode your firebase-key.json file, and store that string as a variable. Then in your code, you would decode that base64 string and parse it into a json file and pass it in to the SDK as the credentials.


Loading...