This commit is contained in:
2026-08-20 21:28:01 +02:00
parent 5f0d5c0e72
commit 5171669d4d
2 changed files with 190 additions and 183 deletions

View File

@@ -5,9 +5,13 @@ import { isSocialChannel, SOCIAL_CHANNELS, SocialChannel } from '@/lib/social-mi
export const dynamic = 'force-dynamic';
// The worker trims its own copy of the secret before sending it, so a stray
// trailing space or CR in the compose env file would otherwise show up here as a
// permanent 401 while both sides still look identical in a hash comparison.
function isAuthorized(request: NextRequest) {
const secret = process.env.INTERNAL_API_SECRET;
return Boolean(secret) && request.headers.get('authorization') === `Bearer ${secret}`;
const secret = process.env.INTERNAL_API_SECRET?.trim();
const presented = request.headers.get('authorization')?.trim().replace(/^Bearer\s+/i, '');
return Boolean(secret) && presented === secret;
}
function approvalDelayHours() {