File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export async function validateWorkflowAccess(
4242 }
4343
4444 const internalSecret = request . headers . get ( 'X-Internal-Secret' )
45- if ( internalSecret === env . INTERNAL_API_SECRET ) {
45+ if ( env . INTERNAL_API_SECRET && internalSecret === env . INTERNAL_API_SECRET ) {
4646 return { workflow }
4747 }
4848
Original file line number Diff line number Diff line change @@ -69,6 +69,16 @@ export async function verifyInternalToken(
6969 * Returns null if authorized, or a NextResponse with error if unauthorized
7070 */
7171export function verifyCronAuth ( request : NextRequest , context ?: string ) : NextResponse | null {
72+ if ( ! env . CRON_SECRET ) {
73+ const contextInfo = context ? ` for ${ context } ` : ''
74+ logger . warn ( `CRON endpoint accessed but CRON_SECRET is not configured${ contextInfo } ` , {
75+ ip : request . headers . get ( 'x-forwarded-for' ) ?? request . headers . get ( 'x-real-ip' ) ?? 'unknown' ,
76+ userAgent : request . headers . get ( 'user-agent' ) ?? 'unknown' ,
77+ context,
78+ } )
79+ return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } )
80+ }
81+
7282 const authHeader = request . headers . get ( 'authorization' )
7383 const expectedAuth = `Bearer ${ env . CRON_SECRET } `
7484 if ( authHeader !== expectedAuth ) {
You can’t perform that action at this time.
0 commit comments