-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Env variables undefined in build but fine in dev #210
Comments
we only load your .env file during development, if you're hosting your app where they don't have a way to load environment variables (vercel, fly, railway, etc) or are trying to run your production app locally, you'll need to update your the reason it works OOTB is because Prisma is also autoloading your .env file for the prisma schema, but to me, it seems like they should first load the schema, find your environment variable you're trying to use and only inject that one. dupe of #208 |
Have you experienced this bug with the latest version of the template?
Yes
Steps to Reproduce
I'm trying to copy some code over from another bare bones remix setup to the indie-stack. It all works fine in dev but after doing
npm run build && npm start
, the env variableSESSION_SECRET
is coming out as undefined.I want to be clear, the stack works in both dev and build if I don't touch anything but I've found something quite puzzling as a result of trying to hunt down the issue.
I've attached a repro with the below setup if you want to the last few steps and run the commands to replicate the issue.
Actual steps to reproduce:
index.tsx
andjoin.tsx
session.server.ts
and just its 1 remaining import fromroot.tsx
routes/index.tsx
file to just return<div>hello</div>
.routes.join.tsx
. All we're doing islogging process.env.SESSION_SECRET
, or any other variable you want to put in.env
.npm run build && npm start
.await getUserByEmail("stuff");
inroutes/join.tsx
and build+run the app again.I have tried this setup from scratch a dozen times with different variations and I can replicate the issue. It comes down to the fact that we need to import and call something from
~/models/user.server
file in a route. You can try the same thing with other routes but it's the same thing.I thought I had missed something but I have tried so many times and I don't see it.
remix-bugged.zip
Expected Behavior
Secrets should be available in build.
Actual Behavior
Secrets are not available in build.
The text was updated successfully, but these errors were encountered: