Skip to content

Commit 4d039e4

Browse files
committed
fix: build issue
1 parent e56f053 commit 4d039e4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/db.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import mongoose from 'mongoose';
22

33
const MONGODB_URI = process.env.MONGODB_URI;
44

5-
if (!MONGODB_URI) {
6-
throw new Error('Please define the MONGODB_URI environment variable inside .env.local');
7-
}
8-
95
interface MongooseCache {
106
conn: mongoose.Connection | null;
117
promise: Promise<mongoose.Connection> | null;
@@ -22,6 +18,10 @@ if (!cached) {
2218
}
2319

2420
async function dbConnect() {
21+
if (!MONGODB_URI) {
22+
throw new Error('Please define the MONGODB_URI environment variable inside .env.local');
23+
}
24+
2525
if (cached.conn) {
2626
return cached.conn;
2727
}

0 commit comments

Comments
 (0)