mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-20 22:24:28 +01:00
fix build error
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
import '@/lib/env.server' // startup env var check
|
|
||||||
|
|
||||||
import './globals.css'
|
import './globals.css'
|
||||||
import { Inter } from 'next/font/google'
|
import { Inter } from 'next/font/google'
|
||||||
import { DM_Sans } from 'next/font/google'
|
import { DM_Sans } from 'next/font/google'
|
||||||
|
|||||||
7
instrumentation.ts
Normal file
7
instrumentation.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { init } from '@/lib/env.server' // startup env var check
|
||||||
|
|
||||||
|
export function register() {
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,20 +12,22 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
export function init() {
|
||||||
zodEnv.parse(process.env)
|
try {
|
||||||
} catch (err) {
|
zodEnv.parse(process.env)
|
||||||
if (err instanceof z.ZodError) {
|
} catch (err) {
|
||||||
const { fieldErrors } = err.flatten()
|
if (err instanceof z.ZodError) {
|
||||||
const errorMessage = Object.entries(fieldErrors)
|
const { fieldErrors } = err.flatten()
|
||||||
.map(([field, errors]) =>
|
const errorMessage = Object.entries(fieldErrors)
|
||||||
errors ? `${field}: ${errors.join(", ")}` : field,
|
.map(([field, errors]) =>
|
||||||
|
errors ? `${field}: ${errors.join(", ")}` : field,
|
||||||
|
)
|
||||||
|
.join("\n ")
|
||||||
|
|
||||||
|
console.error(
|
||||||
|
`Missing environment variables:\n ${errorMessage}`,
|
||||||
)
|
)
|
||||||
.join("\n ")
|
process.exit(1)
|
||||||
|
}
|
||||||
console.error(
|
|
||||||
`Missing environment variables:\n ${errorMessage}`,
|
|
||||||
)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user