10 months ago
Hello!
I have a backend server (NestJS) in a Turborepo that I want to deploy.
I'm using PrismaORM for my database, and to properly apply my data model, I use the command:turbo db:deploy --filter=api => /apps/api > pnpm run db:deploy => pnpx prisma migrate deploy
The problem is that Prisma can't find my environment variable:
error: Environment variable not found: DATABASE_URL.
Even though it is correctly set in the "Variables" tab.
Has anyone encountered similar issues?
5 Replies
10 months ago
Hello,
Perhaps you have not saved (deployed) the changes after adding the variables?
Though looks like nothing has currently crashed!
Best,
Brody
Status changed to Awaiting User Response Railway • 10 months ago
brody
Hello,Perhaps you have not saved (deployed) the changes after adding the variables?Though looks like nothing has currently crashed!Best,Brody
10 months ago
Hi,
Unfortunately, the environments were properly saved.
I ended up disabling the deploy step — I prefer handling it manually until everything works correctly.
However, I'm facing another issue with environment variables on a Next.js app.
Deployment ID:0fd54534-fd41-483d-aef6-30ea0873ea20
The OPENAI_API_KEY is correctly set in the Deployment Details tab as ${{shared.OPENAI_API_KEY}}.
Yet, as seen in the deploy logs, my application fails to access the variable:
Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). at new lg (.next/server/app/api/assistant/route.js:13:25518)The strange part is that another environment variable prefixed with NEXT_PUBLIC_ works fine.
I’m aware that Next.js disables non-NEXT_PUBLIC_ environment variables on the client side, but in this case, I’m on the server side (route.js).
Has anyone encountered a similar issue?
Status changed to Awaiting Railway Response Railway • 10 months ago
10 months ago
Hello,
Everything on our side is working correctly -
Perhaps it would help if you ran your turbo app in lose mode? -
https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#environment-modes
Best,
Brody
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
Man, you saved me!!!
That was exactly the issue — switching to loose mode fixed everything.
I really appreciate your help, thanks a ton!
Status changed to Awaiting Railway Response Railway • 10 months ago
Status changed to Awaiting User Response Railway • 10 months ago
Status changed to Solved brody • 10 months ago
