Before switching to Vite this was working fine:
In the .env declared DATABASE_URL variable:
DATABASE_URL="mysql://root:Password@localhost:3306/myAppDB"
and in the schema.prisma:
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
But after switching to Vite
I need to manually write which gives warning as it’s not safe:
datasource db {
provider = "mysql"
url = "mysql://root:Password@localhost:3306/myAppDB"
}
Cause fetching from the .env
using env()
doesn’t work anymore apparently. Also saw vite recommending to use VITE_
at the start of the environment variables(here’s the link). So I also tried like:
In the .env:
VITE_DATABASE_URL="mysql://root:Password@localhost:3306/myAppDB"schema.prisma
And in the schema.prisma:
datasource db {
provider = "mysql"
url = env("VITE_DATABASE_URL")
}
But this failed as well.