Enviroment Vars not working in Embed

I’ve recently encountered an issue that I’m hoping this community might help me unravel. There was a similar discussion on this forum, but it was presented in a different language and revolved around forked repls, so it doesn’t exactly apply to my situation.

My problem arises when I attempt to embed my project into my website or when I use the cover page without being logged into an account. In these situations, an error message appears, indicating that the ‘password’ is missing. Just to clarify, this ‘password’ is an environment variable and it does exist within my project setup. Interestingly, this issue only manifests when the user is not signed in.

To better illustrate this issue, I invite you to visit: https://replit.com/@HexHands/GOLD-PILE?v=1. Once there, type ‘die’, then ‘y’, and try uploading your score. This will demonstrate the issue i’m currently facing.

Since Replit is running this code on their servers I don’t see why the environment var should disappear.

Thank you.

Might be a problem with how the password environment variable is being handled in your project’s setup. since it doesn’t exist, Try making it. See if it solves the issue.

1 Like

Basically, when you run a Repl, it creates a ghost fork. And when you fork a Repl, the environment variables aren’t saved (assuming you’re using secrets).

2 Likes

I am using secrets though I need it to keep this password safe for my data base.

1 Like

Then the only way to keep the secrets on different accounts is to make it a website as that prevents it from automatically ghost forking.

Have you tried using .env file?

.env files are not supported on Replit. They don’t do anything.

Of course, you can set them in the .replit file, but then anyone could see it.

2 Likes

How did it work before for me…concerned

How would I make my code run on a website? The Replit embed is specifically for that.

No, make your Repl a website. Like host a website on the Repl.

I still do not understand what you mean. Can you please explain or give me an example.

Host a website on your Repl. Like you can use Flask or Django.

Flask example code in main.py:

from flask import Flask

app = Flask(__name__)


app.route('/')
def index():
    return 'Hello world!'


if __name__ == '__main__':
    app.run('0.0.0.0', 81)

html, js, css? using that to recreate it. or flask as i saw qwerty literally just post lol

For some reason I do not understand. :frowning: So just making it host a website will make it work???

Yes. Making your Repl host a website will prevent it from ghost forking when a user runs your Repl.

Ok, that’s weird. Thanks for explaining!

I’ve marked one of my posts as the solution, but please feel free to change it to the post you feel helped you answer the original question most.

oh shoot. The ghost forking issue is unrelated to hosting a website on Repl.it. It’s a platform-specific behavior that may occur in various scenarios and is typically addressed by the Repl.it development team.

you didnt let me finsih typng\

Never mind. It does not work. It just shows the website.