remix
remix copied to clipboard
Remix + Cloudflare Pages + Prisma - Cannot read datasource from environment variable
What version of Remix are you using?
1.7.5
Steps to Reproduce
Start a new base project with remix + cloudflare, and add prisma.
This bug is related to https://github.com/prisma/prisma/issues/15958 on the prisma end.
While this bug seems mostly on the prisma end, I feel like there will be some wiring up needed on the remix end when creating the cloudflare pages handler.
Expected Behavior
Prisma should be able to initialize a datasource from the DATABASE_URL env variable
Actual Behavior
ReferenceError: DATABASE_URL is not defined.
Attempted to access binding using global in modules.
You must use the 2nd `env` parameter passed to exported handlers/Durable Object constructors, or `context.env` with Pages Functions.
Also hit this issue, it's due to the new module syntax for workers/pages. I unblocked myself by shifting to use Remix's cloudflare worker setup instead since that one still uses the older non-module syntax which is supported by Prisma out of the box.
See also https://community.cloudflare.com/t/how-to-access-environment-variables-from-libraries/480041