32 lines
996 B
TypeScript
32 lines
996 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
console.log('[api/recaptcha-config.get] =========================');
|
|
console.log('[api/recaptcha-config.get] GET /api/recaptcha-config - Get public reCAPTCHA configuration');
|
|
|
|
try {
|
|
// Get reCAPTCHA configuration (public access - only return site key)
|
|
const { getRecaptchaConfig } = await import('~/server/utils/admin-config');
|
|
const config = getRecaptchaConfig();
|
|
|
|
console.log('[api/recaptcha-config.get] Returning site key:', config.siteKey ? 'configured' : 'not configured');
|
|
|
|
return {
|
|
success: true,
|
|
data: {
|
|
siteKey: config.siteKey || '',
|
|
// Don't return secret key for public access
|
|
}
|
|
};
|
|
|
|
} catch (error: any) {
|
|
console.error('[api/recaptcha-config.get] ❌ Error getting public reCAPTCHA config:', error);
|
|
|
|
return {
|
|
success: false,
|
|
error: 'Failed to get reCAPTCHA configuration',
|
|
data: {
|
|
siteKey: ''
|
|
}
|
|
};
|
|
}
|
|
});
|