// Test Helcim API connection const HELCIM_API_BASE = 'https://api.helcim.com/v2' export default defineEventHandler(async (event) => { try { const config = useRuntimeConfig(event) // Log token info (safely) const tokenInfo = { hasToken: !!config.public.helcimToken, tokenLength: config.public.helcimToken ? config.public.helcimToken.length : 0, tokenPrefix: config.public.helcimToken ? config.public.helcimToken.substring(0, 10) : null } console.log('Helcim Token Info:', tokenInfo) const helcimToken = config.public.helcimToken || process.env.NUXT_PUBLIC_HELCIM_TOKEN // Try connection test endpoint const response = await $fetch(`${HELCIM_API_BASE}/connection-test`, { method: 'GET', headers: { 'accept': 'application/json', 'api-token': helcimToken } }) return { success: true, message: 'Helcim API connection successful', tokenInfo, connectionResponse: response } } catch (error) { console.error('Helcim test error:', error) return { success: false, message: error.message || 'Failed to connect to Helcim API', statusCode: error.statusCode, tokenInfo: { hasToken: !!useRuntimeConfig().public.helcimToken, tokenLength: useRuntimeConfig().public.helcimToken ? useRuntimeConfig().public.helcimToken.length : 0 } } } })