This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
@@ -10,25 +10,25 @@ export const dynamic = "force-dynamic";
|
||||
const SENSITIVE = ["secret", "api_key", "password", "token", "webhook"];
|
||||
|
||||
function isSensitive(key: string): boolean {
|
||||
const k = key.toLowerCase();
|
||||
return SENSITIVE.some((needle) => k.includes(needle));
|
||||
const k = key.toLowerCase();
|
||||
return SENSITIVE.some((needle) => k.includes(needle));
|
||||
}
|
||||
|
||||
export async function GET(_req: Request) {
|
||||
try {
|
||||
const rows = await prisma.websiteSetting.findMany({
|
||||
select: { key: true, value: true },
|
||||
});
|
||||
try {
|
||||
const rows = await prisma.websiteSetting.findMany({
|
||||
select: { key: true, value: true },
|
||||
});
|
||||
|
||||
const settings: Record<string, string> = {};
|
||||
for (const row of rows) {
|
||||
if (isSensitive(row.key)) continue;
|
||||
settings[row.key] = row.value;
|
||||
}
|
||||
const settings: Record<string, string> = {};
|
||||
for (const row of rows) {
|
||||
if (isSensitive(row.key)) continue;
|
||||
settings[row.key] = row.value;
|
||||
}
|
||||
|
||||
return apiJson(settings);
|
||||
} catch {
|
||||
// DB unavailable — serve an empty settings map rather than a 500.
|
||||
return apiJson({}, { status: 200 });
|
||||
}
|
||||
return apiJson(settings);
|
||||
} catch {
|
||||
// DB unavailable — serve an empty settings map rather than a 500.
|
||||
return apiJson({}, { status: 200 });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user