@@ -3,8 +3,6 @@ import { storeTopThreeUsersInDb } from '../../utils/fetchTopUsersFromDb';
33
44export default async function handler ( req , res ) {
55 console . log ( 'Update contributors API called' ) ;
6- console . log ( 'Auth header present:' , ! ! req . headers . authorization ) ;
7- console . log ( 'Expected token:' , process . env . FCM_GITHUB_TOKEN ?. substring ( 0 , 5 ) + '...' ) ;
86
97 const authHeader = req . headers . authorization ;
108 if ( ! authHeader ) {
@@ -13,12 +11,19 @@ export default async function handler(req, res) {
1311 }
1412
1513 const token = authHeader . split ( ' ' ) [ 1 ] ;
16- console . log ( 'Received token:' , token ?. substring ( 0 , 5 ) + '...' ) ;
14+
15+ // Debug logging (first 5 chars only for security)
16+ console . log ( 'Environment token length:' , process . env . FCM_GITHUB_TOKEN ?. length ) ;
17+ console . log ( 'Received token length:' , token ?. length ) ;
18+ console . log ( 'Environment token prefix:' , process . env . FCM_GITHUB_TOKEN ?. substring ( 0 , 5 ) ) ;
19+ console . log ( 'Received token prefix:' , token ?. substring ( 0 , 5 ) ) ;
1720
1821 if ( ! token || token !== process . env . FCM_GITHUB_TOKEN ) {
19- console . error ( 'Invalid authorization token' ) ;
20- console . log ( 'Token match:' , token === process . env . FCM_GITHUB_TOKEN ) ;
21- return res . status ( 401 ) . json ( { error : 'Unauthorized' } ) ;
22+ console . error ( 'Token validation failed' ) ;
23+ return res . status ( 401 ) . json ( {
24+ error : 'Unauthorized' ,
25+ details : 'Token validation failed'
26+ } ) ;
2227 }
2328
2429 try {
@@ -40,3 +45,4 @@ export default async function handler(req, res) {
4045 return res . status ( 500 ) . json ( { error : 'Internal server error' , details : error . message } ) ;
4146 }
4247}
48+
0 commit comments