NeonDB Nuxt connection
# pages-help
t
Hey, I'm trying to connect to NeonDB via their serverless driver. All of this is in Nuxt api function, but Cloudflare keeps throwing errors with this message: "The database host is 'localhost', which is the default host when none is set. If that's intentional, please ignore this warning. If not, perhaps an environment variable has not been set, or has not been passed to the library?" But I set all of env variables so I don't see what is wrong with it, is it not ready to be used with framework and only works in plain worker?
r
@TheSpik3 Functions don't have a global
process.env
. Are you properly passing in the
env
like it'd documented here? https://github.com/neondatabase/serverless#how-to-use-it Is this happening locally, and if so are you setting the variables in
.dev.vars
?
t
I solved it.. There was a confusion as Nuxt injects runtime config with prefix - in .env you have NUXT_DB_URL and in Nuxt.config you have dbUrl, this doesn't happen on CF Pages, so you have to define it from process.env - dbUrl: process.env.NUXT_DB_URL 😅
Unfortunately local development w/Nuxt and Neon DB serverless driver is now a no-go, it breaks in every way possible and errors all over the place