R
Railway2mo ago
Mike

how to get shared variables?

hello, been trying to use railway to deploy a discord.js bot, but i can't seem to get my token working. GitHub understandably won't let me upload a discord token to my repo, since other people could see it and mess with my bot, so i'm tryna figure out shared variables. i put my token as a shared variable on my project, shared it to my deployment, and i put "token":"${{shared.token}}" into my config.json, where my token once was. (my config.json, where i'm trying to access the variable ↓)
{
"token": "${{shared.token}}",
"clientId": "(my bot's ID is here.)"
}
{
"token": "${{shared.token}}",
"clientId": "(my bot's ID is here.)"
}
however, when trying to use const {token} = require('./config.json') and deploying it, it says i have an invalid token. my code is being run on railway, from a GitHub repo. what exactly am i doing wrong here, and what should i do to get my shared variables? my project id: d318ba42-07f6-4530-bc4e-7154f0f6d824
5 Replies
Percy
Percy2mo ago
Project ID: d318ba42-07f6-4530-bc4e-7154f0f6d824
Mike
MikeOP2mo ago
P.S. i'm stupid. i named my env file secrets.env instead of just .env. after properly renaming it, adding token="${{shared.token}}" and using process.env.token worked.
Brody
Brody2mo ago
please do not upload a secrets.env file to GitHub
Mike
MikeOP2mo ago
i misnamed it, was supposed to be just .env.
Brody
Brody2mo ago
it shouldn't be either, you shouldn't have files that contain sensitive information in your repo
Want results from more Discord servers?
Add your server