Ask coding questions

← Back to all posts
How to hide stuff in repl.it
proryan (75)

I'm trying to hide my database url and .env files are not working for me at all... How would I hide my db url?

Answered by Bookie0 (6287) [earned 5 cycles]
View Answer
Comments
hotnewtop
Bookie0 (6287)

If you're not an explorer, you have to create a file called .env and then you can put stuff inside. If you're an explorer, they sadly took that feature off and made it into a GUI, you can find it here (the lock icon):

Where you can add keys and their values

It'll tell you how to access those variables.

:)

proryan (75)

@Bookie0 Yes, I know that but those variables throw an error when someone else besides me treis to run the code...

Bookie0 (6287)

What’s the error? Can you send a screenshot please? Also what was the code; did you simply output one of the variables in the .env? In that case, I don’t think any other user than you can view it as only the owner of a repl (and anyone who has edit access in a multiplayer repl) can have access to that bc variable.
@proryan

testtest65 (0)

@Bookie0 I have logged in to one of my test accounts that I use to test my projects. Using that test account I have run the same program simulating how it would be like if I posted this and you ran it. This Is

the error I got into

proryan (75)

@Bookie0 I can vouch that @testtest65 is one of my test accounts btw

Bookie0 (6287)

@testtest65 yeah that's the problem with replDB, it creates a DB for each different person lol..

proryan (75)

@Bookie0 I fixed the problem of it creating a db for every person but I want to hide my api key for my db so nobody else can access it. (P.S. Thanks for actually staying on my question and not giving up. For that (and probably because there is no solution) I'm marking your answer as correct (Even though it didn't really help :))

Bookie0 (6287)

@proryan Alright. And no problem, I always try to keep helping! :D

Good luck :)

BD103 (139)

Try renaming the .env variable to dburl (idk if the underscore bugs it out or not), then try os.getenv("dburl") instead. (It returns None if no variable is set.) Plus, the Repl Env tab is buggy, so that may be your issue.

proryan (75)

@BD103 Other users can't access it because its private to only me. I want something that can be stored as a variable and I can use in the program but I don't want users to see. Kinda like a api key...

proryan (75)

@Coder100 Env variables throw and Not Found error when someone else besides me runs the code :(

Coder100 (18199)

yeah ofc that's why its called a secret others can't access sit @proryan