fix: resolve React Error #310 and refactor admin section
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
- Fix React bug #33580: remove Suspense boundaries co-located with Link components - Delete settings/loading.tsx and admin/loading.tsx (root cause of race condition) - Convert all admin navigation from Next.js Link to anchor tags - Move admin pages to dedicated (admin) route group - Add AdminHeader matching main header visual design - Add AdminSidebar with anchor-based navigation - Add /api/admin/models route handler (replaces server actions for GET) - Add /api/debug/client-error for server-side browser error reporting - Add useNoteRefreshOptional() to fix crash in AdminHeader - Hide Admin Dashboard menu for non-admin users - Change app icons from yellow to blue (#3A7CA5) matching brand primary - Fix admin search bar width to match main header Made-with: Cursor
This commit is contained in:
@@ -1,16 +1,36 @@
|
||||
import prisma from './prisma'
|
||||
|
||||
// Environment variable fallbacks for system config keys
|
||||
const ENV_FALLBACKS: Record<string, string> = {
|
||||
AI_PROVIDER_TAGS: process.env.AI_PROVIDER_TAGS || '',
|
||||
AI_MODEL_TAGS: process.env.AI_MODEL_TAGS || '',
|
||||
AI_PROVIDER_EMBEDDING: process.env.AI_PROVIDER_EMBEDDING || '',
|
||||
AI_MODEL_EMBEDDING: process.env.AI_MODEL_EMBEDDING || '',
|
||||
AI_PROVIDER_CHAT: process.env.AI_PROVIDER_CHAT || '',
|
||||
AI_MODEL_CHAT: process.env.AI_MODEL_CHAT || '',
|
||||
OLLAMA_BASE_URL: process.env.OLLAMA_BASE_URL || '',
|
||||
OPENAI_API_KEY: process.env.OPENAI_API_KEY || '',
|
||||
CUSTOM_OPENAI_API_KEY: process.env.CUSTOM_OPENAI_API_KEY || '',
|
||||
CUSTOM_OPENAI_BASE_URL: process.env.CUSTOM_OPENAI_BASE_URL || '',
|
||||
ALLOW_REGISTRATION: process.env.ALLOW_REGISTRATION || '',
|
||||
NEXTAUTH_URL: process.env.NEXTAUTH_URL || '',
|
||||
}
|
||||
|
||||
export async function getSystemConfig() {
|
||||
let dbConfig: Record<string, string> = {}
|
||||
try {
|
||||
const configs = await prisma.systemConfig.findMany()
|
||||
return configs.reduce((acc, conf) => {
|
||||
dbConfig = configs.reduce((acc, conf) => {
|
||||
acc[conf.key] = conf.value
|
||||
return acc
|
||||
}, {} as Record<string, string>)
|
||||
} catch (e) {
|
||||
console.error('Failed to load system config from DB:', e)
|
||||
return {}
|
||||
}
|
||||
|
||||
// Merge: DB values take precedence, env vars as fallback
|
||||
const merged = { ...ENV_FALLBACKS, ...dbConfig }
|
||||
return merged
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user