nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
970 stars 54 forks source link

Correct config for Prisma with Supabase on Cloudflare #241

Open mtzrmzia opened 2 months ago

mtzrmzia commented 2 months ago

Describe the bug I'm trying to relocate my Vercel projects to Cloudflare through NuxtHub. I'm using Prisma ORM with Supabase and on Vercel deploy the project works as expected, but in Cloudflare not. I got 500: Cannot read properties of undefined (reading 'exec'). error but in local works!

Steps to reproduce Steps to reproduce the behavior:

  1. Install prisma and @prisma/client dependencies then add prisma generate to build command:
{
  "name": "esteba-app-appointments",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "prisma generate && nuxt build",
  },
  "dependencies": {
    "@prisma/client": "^5.18.0",
    "@vueuse/core": "^11.0.1",
    "nuxt": "^3.13.0",
    "vue": "latest",
  },
  "devDependencies": {
    "prisma": "^5.18.0",
    "wrangler": "^3.72.2"
  },
  "packageManager": "yarn@1.22.22"
}
  1. Create prisma/schema.prisma file:
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
  1. set supabase credentials on environment variables project

and thats it, on Vercel this works

Expected behavior Request sent as expected

I'm doing my research, and this issue happens to another person Cloudflare issue

atinux commented 2 months ago

Duplicate of #38

Would you mind reading https://github.com/nuxt-hub/core/pull/58/files and see if this works?

mtzrmzia commented 2 months ago

Duplicate of #38

Would you mind reading https://github.com/nuxt-hub/core/pull/58/files and see if this works?

The example uses sqlite and ignores the DATABASE_URL but i'm using postgresql with supabase... just dont work

atinux commented 2 months ago

I guess you also read https://www.prisma.io/docs/orm/prisma-client/deployment/edge/deploy-to-cloudflare ?

CristobalMedrano commented 2 months ago

I had a similar problem, you could try this https://github.com/prisma/prisma/issues/23500#issuecomment-2147548083. It seems to be a problem with Nitro and Prisma