diff --git a/attached_assets/image_1768228239998.png b/attached_assets/image_1768228239998.png new file mode 100644 index 0000000..0cb9b79 Binary files /dev/null and b/attached_assets/image_1768228239998.png differ diff --git a/server/routes.ts b/server/routes.ts index 20e1775..5987ce8 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -272,6 +272,80 @@ export async function registerRoutes(app: Express): Promise { }); }); + // Sitemap.xml for SEO + app.get("/sitemap.xml", async (req, res) => { + try { + const baseUrl = "https://video.folx.tv"; + const videos = await storage.getVideos(1000, 0); + + // Helper to escape XML special characters + const escapeXml = (str: string) => { + if (!str) return ''; + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + }; + + let xml = ` + + + ${baseUrl}/ + daily + 1.0 + +`; + + for (const video of videos) { + const shortId = video.id.replace(/-/g, '').substring(0, 8); + const lastmod = video.createdAt ? new Date(video.createdAt).toISOString().split('T')[0] : new Date().toISOString().split('T')[0]; + const safeTitle = escapeXml(video.title); + const safeDescription = escapeXml(video.description || video.title); + const safeThumbnail = escapeXml(video.thumbnailUrl || ''); + + xml += ` + ${baseUrl}/video/${shortId} + ${lastmod} + weekly + 0.8 + + ${safeThumbnail} + ${safeTitle} + ${safeDescription} + ${video.duration || 0} + + +`; + } + + xml += ``; + + res.setHeader('Content-Type', 'application/xml'); + res.setHeader('Cache-Control', 'public, max-age=3600'); + res.send(xml); + } catch (error) { + console.error('Error generating sitemap:', error); + res.status(500).send('Error generating sitemap'); + } + }); + + // Robots.txt + app.get("/robots.txt", (req, res) => { + const baseUrl = "https://video.folx.tv"; + const robots = `User-agent: * +Allow: / +Disallow: /admin +Disallow: /api/ + +Sitemap: ${baseUrl}/sitemap.xml +`; + res.setHeader('Content-Type', 'text/plain'); + res.send(robots); + }); + app.get("/api/auth/me", authenticate, async (req, res) => { try { const user = await storage.getUser(req.session.userId!);