Hey there, hope you’re having a great day!
Here is the problem I’m facing. I need my secrets to be set as environment variables during build time. They do set when running the repl. But when building(before running), they are not accessible as env vars. Refer to this simple typescript repl I’ve created.
Now, I need my secrets in the build(compile) process. If you need more details, I’m building a remix app that uses Prisma as an ORM to connect to DB. If there is no DATABASE_URI variable set in the environment, it will throw an error that I can’t find it. But it works when running the server normally in the shell(terminal).
I need my secrets at build time
Hi @amirhossein-shakeri silly question, but have you clicked the “save” button on that secret you’re showing in the image.
Are you running that sh command manually? That may be the problem, it might be that you need to press the run button for the env vars to actually be set. Try changing the .replit file to run your sh command?
This is just a suggestion, I’m not entirely sure if that’s the way it works, so let me know!
@CodingCactus, Yes, I’ve set the secret and saved it(Just clicked the edit button so that it’s visible in the screenshot).
You know what? When I try to run the app using the provided shell(terminal) manually, there is no problem with the build and I can simply get the app up and running(env and stuff are ok). But when using the (green)play button on top of the screen, the problem happens! So the problem is that “secrets are not set as environment variables at compile(build) time”.
Checkout my repl: AmirhosseinShak/SecretsNotWorkingInBuild
Hi @amirhossein-shakeri I’ve come to a conclusion that this might be a bug. You can report bugs by clicking the question mark in the sidebar.
For now, if you combine the compile and run commands into a run command, it seems to work.
I don’t believe that this is a bug. I’ve experienced this issue before and it’s to do with how the
.replit file is configured.
Could you link the repl @amirhossein-shakeri?
The repl details are above
@DillonB07 here is the repl @AmirhosseinShak/SecretsNotWorkingInBuild, Sorry I can’t put the link to the repl because it disappears or not shown correctly(The link is already at the first message on the topic but you can only see it when editing the topic).
Since the environment variable was DATABASE_URL and the database URL in this repl was a simple local SQLite, I hardcoded it so that it works for now. This might not be a bug since it’s mentioned in the docs(I think) but I need this to work anyway. So I’ll probably report it or ask for this feature(If not a bug). I’ll probably send updates on this topic if I got any response