how to get shared variables?

fourthegreat
TRIAL

a year ago

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.)"
}

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

0 Replies

fourthegreat
TRIAL

a year 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.


a year ago

please do not upload a secrets.env file to GitHub


fourthegreat
TRIAL

a year ago

i misnamed it, was supposed to be just .env.


a year ago

it shouldn't be either, you shouldn't have files that contain sensitive information in your repo