Hi! I'd like to deploy the prisma + apollo server ...
# random
j
Hi! I'd like to deploy the prisma + apollo server as a serverless function to Firebase. Firebase manages environment variables with
functions.config()
(https://firebase.google.com/docs/functions/config-env) But to connect to a database, prisma uses dotenv:
Copy code
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
Is it possible to access
functions.config()
in
schema.prisma
file? I definitely donot want to hard code user name and password.
j
You can just write the config() value into the env for example
Or supply it explicitly to PrismaClient
Let me find some links for that
j
@janpio Thanks!❤️ so there're 3 files:
.env
Copy code
DATABASE_URL="postgresql://...
schema.prisma
Copy code
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
index.ts
Copy code
const prisma = new PrismaClient({
  datasources: {
    db: {
      url: functions.config().prisma.db,
    },
  },
})
I'll try it out
👍 1
j
Depending on how you develop locally, you will want to have some special code to only do the config() thing on Firebase.
We were quite shocked when we learned you can not really set env vars on Firebase Functions 🤷
😆 1