This commit is contained in:
46
scripts/test-og-images.ts
Normal file
46
scripts/test-og-images.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import * as http from 'http';
|
||||
|
||||
const baseUrl = 'http://localhost:3010';
|
||||
const paths = [
|
||||
'/en/opengraph-image',
|
||||
'/de/opengraph-image',
|
||||
'/en/blog/opengraph-image',
|
||||
'/en/contact/opengraph-image',
|
||||
'/en/products/opengraph-image',
|
||||
'/en/team/opengraph-image',
|
||||
];
|
||||
|
||||
async function testUrl(path: string) {
|
||||
return new Promise((resolve) => {
|
||||
const url = `${baseUrl}${path}`;
|
||||
console.log(`Testing ${url}...`);
|
||||
const req = http.get(url, (res) => {
|
||||
console.log(` Status: ${res.statusCode}`);
|
||||
console.log(` Content-Type: ${res.headers['content-type']}`);
|
||||
resolve(res.statusCode === 200);
|
||||
});
|
||||
req.on('error', (e) => {
|
||||
console.error(` Error: ${e.message}`);
|
||||
resolve(false);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
async function run() {
|
||||
let allPassed = true;
|
||||
for (const path of paths) {
|
||||
const passed = await testUrl(path);
|
||||
if (!passed) allPassed = false;
|
||||
}
|
||||
|
||||
if (allPassed) {
|
||||
console.log('\n✅ All OG images are working!');
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.log('\n❌ Some OG images failed.');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user