From 667328b16662a502aba40bf008b697ef394ae8e4 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 8 Nov 2025 15:22:33 -0600 Subject: [PATCH] Conditionally add build identifier to --- README.md | 5 +++++ app/admin/configuration/export.json/route.ts | 6 ++++-- app/layout.tsx | 7 +++++++ src/admin/config/AdminAppConfigurationClient.tsx | 14 ++++++++++++++ src/admin/config/index.tsx | 14 ++++++++++++-- src/app/config.ts | 6 ++++++ 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0b673c79..3ee598ce 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,11 @@ Create Upstash Redis store from storage tab of Vercel dashboard and link to your - urls must begin with 'https' - ⚠️ this will invoke arbitrary script execution on every page—use with caution +### Debugging +- `DISABLE_DEBUG_OUTPUTS = 1` + - removes build identifier in `` + - disables `/admin/configuration/export.json` + ## Alternate storage providers Only one storage adapter—Vercel Blob, Cloudflare R2, AWS S3, or MinIO—can be used at a time. Ideally, this is configured before photos are uploaded (see [Issue #34](https://github.com/sambecker/exif-photo-blog/issues/34) for migration considerations). If you have multiple adapters, you can set one as preferred by storing `aws-s3`, `cloudflare-r2`, `minio`, or `vercel-blob` in `NEXT_PUBLIC_STORAGE_PREFERENCE`. See [FAQ](#will-there-be-support-for-image-storage-providers-beyond-vercel-aws-and-cloudflare) regarding unsupported providers. diff --git a/app/admin/configuration/export.json/route.ts b/app/admin/configuration/export.json/route.ts index b6aa32d0..c5c34a45 100644 --- a/app/admin/configuration/export.json/route.ts +++ b/app/admin/configuration/export.json/route.ts @@ -1,5 +1,7 @@ -import { APP_CONFIGURATION } from '@/app/config'; +import { APP_CONFIGURATION, DEBUG_OUTPUTS_ENABLED } from '@/app/config'; export async function GET() { - return Response.json(APP_CONFIGURATION); + return DEBUG_OUTPUTS_ENABLED + ? Response.json(APP_CONFIGURATION) + : new Response('Debugging disabled', { status: 404 }); }; diff --git a/app/layout.tsx b/app/layout.tsx index 009f76f4..e4a94a23 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -11,6 +11,8 @@ import { SITE_FEEDS_ENABLED, ADMIN_DEBUG_TOOLS_ENABLED, PAGE_SCRIPT_URLS, + VERCEL_GIT_COMMIT_SHA_SHORT, + DEBUG_OUTPUTS_ENABLED, } from '@/app/config'; import AppStateProvider from '@/app/AppStateProvider'; import ToasterWithThemes from '@/toast/ToasterWithThemes'; @@ -70,6 +72,11 @@ export const metadata: Metadata = { type: 'image/png', sizes: '180x180', }], + ...DEBUG_OUTPUTS_ENABLED && { + other: { + 'build': VERCEL_GIT_COMMIT_SHA_SHORT ?? 'unknown', + }, + }, ...SITE_FEEDS_ENABLED && { alternates: { types: { diff --git a/src/admin/config/AdminAppConfigurationClient.tsx b/src/admin/config/AdminAppConfigurationClient.tsx index ef9f4eb2..a74fc179 100644 --- a/src/admin/config/AdminAppConfigurationClient.tsx +++ b/src/admin/config/AdminAppConfigurationClient.tsx @@ -133,6 +133,8 @@ export default function AdminAppConfigurationClient({ // Scripts & Analytics hasPageScriptUrls, pageScriptUrls, + // Debugging + isDebuggingEnabled, // Internal areInternalToolsEnabled, areAdminDebugToolsEnabled, @@ -972,6 +974,18 @@ export default function AdminAppConfigurationClient({ {renderEnvVars(['PAGE_SCRIPT_URLS'])} ; + case 'Debugging': + return <> + + Set environment variable to {'"1"'} to disable build identifier + and admin configuration export: + {renderEnvVars(['DISABLE_DEBUG_OUTPUTS'])} + + ; case 'Internal': return <> , +}, { + title: 'Debugging', + required: false, + icon: , }, { title: 'Internal', required: false, - icon: , + icon: , }] as const satisfies AdminConfigSection[]; export type ConfigSectionKey = typeof ADMIN_CONFIG_SECTIONS[number]['title']; diff --git a/src/app/config.ts b/src/app/config.ts index 05d007fd..35b90c1a 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -386,6 +386,10 @@ export const PAGE_SCRIPT_URLS = process.env.PAGE_SCRIPT_URLS .filter(url => url.startsWith('https://')) : []; +// DEBUGGING + +export const DEBUG_OUTPUTS_ENABLED = process.env.DISABLE_DEBUG_OUTPUTS !== '1'; + // INTERNAL export const ADMIN_DEBUG_TOOLS_ENABLED = process.env.ADMIN_DEBUG_TOOLS === '1'; @@ -510,6 +514,8 @@ export const APP_CONFIGURATION = { // Scripts & Analytics hasPageScriptUrls: PAGE_SCRIPT_URLS.length > 0, pageScriptUrls: PAGE_SCRIPT_URLS, + // Debugging + isDebuggingEnabled: DEBUG_OUTPUTS_ENABLED, // Internal areInternalToolsEnabled: ( ADMIN_DEBUG_TOOLS_ENABLED ||