feat: Add chat embeds v1

Youtube and Website metadata embeds
This commit is contained in:
2026-04-04 04:47:04 +02:00
parent 35352923a5
commit 84fa45985a
25 changed files with 759 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
import { Router } from 'express';
import { resolveAndValidateHost, safeFetch } from './ssrf-guard';
const router = Router();
@@ -10,14 +11,20 @@ router.get('/image-proxy', async (req, res) => {
return res.status(400).json({ error: 'Invalid URL' });
}
const hostAllowed = await resolveAndValidateHost(url);
if (!hostAllowed) {
return res.status(400).json({ error: 'URL resolves to a blocked address' });
}
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 8000);
const response = await fetch(url, { redirect: 'follow', signal: controller.signal });
const response = await safeFetch(url, { signal: controller.signal });
clearTimeout(timeout);
if (!response.ok) {
return res.status(response.status).end();
if (!response || !response.ok) {
return res.status(response?.status ?? 502).end();
}
const contentType = response.headers.get('content-type') || '';