Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix: path validation for metadata tags resolution (#757)
Ben Fornefeld31fce90f6b2f
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsxindex 663e55fd8..f2c8f1603 100644--- a/apps/web/src/app/layout.tsx+++ b/apps/web/src/app/layout.tsx@@ -11,13 +11,28 @@ import { headers } from 'next/headers'async function isValidPath(pathname: string) {try {- const docsDirectory = await glob('**/*.mdx', {- cwd: `src/app/(docs)${pathname}`,+ const baseUrl = process.env.VERCEL_URL+ ? `https://${process.env.VERCEL_URL}`+ : 'https://e2b.dev'+ const sitemapUrl = `${baseUrl}/sitemap.xml`++ // NOTE: Expects all valid paths to be in one sitemap.xml file+ const response = await fetch(sitemapUrl, {+ cache: 'force-cache',})- return docsDirectory.length > 0+ if (!response.ok) {+ console.error('Sitemap fetch failed:', response.statusText)+ return false+ }++ const sitemapXml = await response.text()+ const targetUrl = `https://e2b.dev${pathname}`+ const isValid = sitemapXml.includes(`<loc>${targetUrl}</loc>`)++ return isValid} catch (error) {- console.error('Error validating path in generateMetadata:', error)+ console.error('Error validating path in isValidPath:', error)return false}}diff --git a/apps/web/src/app/sitemap.ts b/apps/web/src/app/sitemap.tsindex 9babbd265..bd6708c26 100644--- a/apps/web/src/app/sitemap.ts+++ b/apps/web/src/app/sitemap.ts@@ -4,6 +4,8 @@ import { getPageForSitemap } from '@/utils/sitemap'export const dynamic = 'force-static'+// NOTE: Sitemap should not be split into multiple files.+// This would break path validation in [app/layout.tsx]export default async function sitemap(): Promise<MetadataRoute.Sitemap> {const docsDirectory = path.join(process.env.NODE_ENV === 'production'