In my prisma.yml if I try to use env variables the...
# orm-help
l
In my prisma.yml if I try to use env variables then my requests using prisma client don't work does anyone know why?
@divyendu Is this a bug?
d
Did you regenerate the client after adding environment variables?
l
Yes I've done it twice now just to check, had the secret as
Copy code
secret: secret123
then generated, got the token and made a request and it works, then I do the same steps but with ```secret: ${env:PRISMA_SECRET} and it gives me this error
Your token is invalid. It might have expired or you might be using a token from a different project.
I also did a similar test with trying endpoint as a env variable instead and that isn't working for me either
d
When do you get this error?
l
When making a query request in playground when I set secret to an env variable, but when i just a string it works fine
The same for if endpoint is a string it works fine but if I set it to an env variable I get an error
Copy code
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var prisma_lib_1 = require("prisma-client-lib");
var typeDefs = require("./prisma-schema").typeDefs;

var models = [
  {
    name: "Post",
    embedded: false
  }
];
exports.Prisma = prisma_lib_1.makePrismaClientClass({
  typeDefs,
  models,
  endpoint: `${process.env["PRISMA_URL"]}`,
  secret: `secret123`
});
exports.prisma = new exports.Prisma();
That's the prisma client output when I use an env variable for endpoint
d
This looks correct as long as PRISMA_URL is available in environment. Did you do a Prisma deploy after setting the secret?
l
Yeah I did a Prisma deploy, and I have a .env file with
Copy code
PRISMA_URL="<https://eu1.prisma.sh/lewis-df7b16/test/dev>"
at the root
Can the prisma client access the .env file
d
Client is running through the node application! You need to make the node application read env file using dotenv package or something and then it would work with the Prisma client.
l
I have
Copy code
require("dotenv").config();
in my yoga server which is allowing me to use env variables in that, but it doesn't seem to be working in prisma client for some reason
d
Weird, can you please share a small reproduction repository?