From 6bfb078e45fcd26b52f31a736071f48c5c0177c7 Mon Sep 17 00:00:00 2001 From: Jennie Robinson Faber Date: Fri, 1 May 2026 10:46:47 +0100 Subject: [PATCH] fix(mongoose): fall back to process.env when run outside Nitro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit connectDB() called useRuntimeConfig() unconditionally — works inside the Nuxt/Nitro runtime but throws ReferenceError for standalone Node scripts (seed-members.js, seed-tags.js, etc.). CI exposed this when trying to run seed-all.js. Detect the auto-import and fall back to process.env when it's not available; preserves Nitro behavior. --- server/utils/mongoose.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/utils/mongoose.js b/server/utils/mongoose.js index e75a5b4..1e06946 100644 --- a/server/utils/mongoose.js +++ b/server/utils/mongoose.js @@ -7,7 +7,10 @@ export const connectDB = async () => { return; } - const MONGODB_URI = useRuntimeConfig().mongodbUri; + const MONGODB_URI = + typeof useRuntimeConfig === 'function' + ? useRuntimeConfig().mongodbUri + : process.env.NUXT_MONGODB_URI || process.env.MONGODB_URI; try { await mongoose.connect(MONGODB_URI, {