env not required during build

This commit is contained in:
Sebastian Seedorf
2022-08-18 11:27:29 +02:00
parent 044943f19a
commit 0ae9f4f546
3 changed files with 9 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ const {
} = getConfig()
async function getDatabase() {
if (!MONGO_URL || !MONGO_DB) return undefined
const url = `mongodb://${MONGO_USER ? `${MONGO_USER}:${MONGO_PASS ?? ''}@` : ''}${MONGO_URL}`
const client = new MongoClient(url)
await client.connect()

4
src/next-types.d.ts vendored
View File

@@ -1,7 +1,7 @@
declare module 'next/config' {
export interface ServerRuntimeConfig {
MONGO_URL: string
MONGO_DB: string
MONGO_URL?: string
MONGO_DB?: string
MONGO_USER?: string
MONGO_PASS?: string
}