-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-vercel-api.js
More file actions
77 lines (64 loc) · 2.25 KB
/
Copy pathtest-vercel-api.js
File metadata and controls
77 lines (64 loc) · 2.25 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Test Vercel API endpoint
import https from 'https';
// Your actual Vercel URL
const VERCEL_URL = 'https://google-bfxm3xffd-seo7077s-projects.vercel.app';
const testData = {
adId: '747836975928',
campaignId: '22475792074',
adGroupId: '177122875614',
campaignName: 'Honest Healthwise Low Sex Drive',
adGroupName: 'Low Sex Drive',
finalUrl: 'https://www.honesthealthwise.com/article/the-5-best-libido-boosters-of-2025',
performanceScore: 5
};
const postData = JSON.stringify(testData);
const options = {
hostname: VERCEL_URL.replace('https://', '').replace('http://', ''),
port: 443,
path: '/api/generate-ad',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
};
console.log('🧪 Testing Vercel API Endpoint...');
console.log(`🌐 URL: ${VERCEL_URL}/api/generate-ad`);
console.log('📊 Test data:', testData);
console.log('');
const req = https.request(options, (res) => {
console.log(`📡 Status: ${res.statusCode}`);
console.log('📋 Headers:', res.headers);
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('\n📄 Response received:');
try {
const parsed = JSON.parse(data);
console.log(JSON.stringify(parsed, null, 2));
if (parsed.success) {
console.log('\n✅ Test successful!');
console.log(`- Variants generated: ${parsed.variantsGenerated || 'N/A'}`);
console.log(`- Ad Generator records: ${parsed.adGeneratorRecords || 'N/A'}`);
console.log(`- Upload Queue records: ${parsed.uploadQueueRecords || 'N/A'}`);
} else {
console.log('\n❌ Test failed:', parsed.error);
}
} catch (e) {
console.log('❌ Invalid JSON response:');
console.log('Raw response:', data);
}
});
});
req.on('error', (error) => {
console.error('❌ Request error:', error.message);
});
req.on('timeout', () => {
console.error('❌ Request timeout');
req.destroy();
});
req.setTimeout(60000); // 60 second timeout for OpenAI/Airtable calls
req.write(postData);
req.end();