UseDatabase feature -- Build nitro with environment variable #3420
ClemenF
started this conversation in
Help Wanted
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have a small api project build on nitrojs. I use the exprirement feature database (db0) to connect to a postgresql database.
On my local env, i don't have any issue but i have some question about the deployment phase.
I run the build command and then the preview without any issue but once i call my API which do a call to database, it displayed an error
Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a stringtriggered in file :.output/server/node_modules/pg/lib/crypto/sasl.js:36:11After some debugging, I found out that the config pass to the pg client is empty. In
.output/server/chunks/nitro/nitro.mjs:I use the file nitro.config.ts to configure my database :
And I have a .env file next to it which define the variable.
I understood that when running the commande
npm run build, it doesn't use any of the environment variable.To have it work, i can use the following command :
node --env-file=.env ./node_modules/nitropack/dist/cli/index.mjs buildand then, I have my nitro api working well.Is there any other way to have my file built with variable environment well configured ?
All reactions