Ask coding questions

← Back to all posts
Replit's secret (environment variables) not working
Trillionz

I recently noticed .env are no longer allowed in replit with an alternative to use the environment variable secrets.

I tried using that but it never works, i have tried to find a solution online but since it's a new feature I have only seen similar problems without solutions.

How can I go about this..

Voters
ceilingrat
Trillionz
Comments
hotnewtop
Trillionz

Finally found the problem. This new environment variable secrets doesn't work in shell. it returns undefined in shell

Bookie0

You can't make .env files anymore, you'll have to use this new GUI by clicking the lock icon in the sidebar (near where the files are kept). Then you just enter the name of a key and its value. And in the repl, you do import os, and my_secret = os.environ['name of your key here']. Good luck! :)

Trillionz

@Bookie0 thanks for answering but it seems you don't understand my complain. What you're suggesting is what am complaining that it isn't working

Bookie0

@Trillionz Ah ok, so what exactly is your problem?

You say:

Replit's secret (environment variables) not working

and

I tried using that but it never works

so what isn't working?

Trillionz

@Bookie0 the secret (environment variable). inserting the secrets in your app as process.env['Token'] is what wasn't working. But i have seen the solution. thanks

Bookie0

@Trillionz ah hum okay then. :)

RakoGames

@Trillionz what is it?

LeoXu2

shuld be here

Vandesm14

Use the secrets button on the sidebar. More info here: https://docs.replit.com/repls/secrets-environment-variables