File size: 963 Bytes
073aa17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { NextRequest, NextResponse } from 'next/server';

/**
 * Test endpoint to check if HF_TOKEN is available
 * Useful for debugging token configuration
 */
export async function GET(request: NextRequest) {
  const token = 
    process.env.HF_TOKEN || 
    process.env.HUGGINGFACE_TOKEN || 
    process.env.HF_API_TOKEN ||
    process.env.HUGGING_FACE_HUB_TOKEN ||
    null;
  
  const envKeys = Object.keys(process.env).filter(k => 
    k.includes('HF') || k.includes('TOKEN') || k.includes('HUGGING')
  );
  
  return NextResponse.json({
    tokenFound: !!token,
    tokenLength: token ? token.length : 0,
    tokenPrefix: token ? token.substring(0, 10) + '...' : null,
    checkedVariables: [
      'HF_TOKEN',
      'HUGGINGFACE_TOKEN', 
      'HF_API_TOKEN',
      'HUGGING_FACE_HUB_TOKEN'
    ],
    availableEnvVars: envKeys,
    allEnvVarsCount: Object.keys(process.env).length,
  }, {
    headers: {
      'Cache-Control': 'no-store',
    }
  });
}