Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Remove canonical links for landing page, blog, and changelog

Vasek Mlejnsky9eff4f3bfa3c
diff --git a/apps/reverse-proxy/middleware.ts b/apps/reverse-proxy/middleware.ts
index c68463ca4..b39570466 100644
--- a/apps/reverse-proxy/middleware.ts
+++ b/apps/reverse-proxy/middleware.ts
@@ -6,32 +6,58 @@ export async function middleware(req: NextRequest): Promise<NextResponse> {
const url = new URL(req.nextUrl.toString())
url.protocol = 'https'
- url.hostname = 'e2b-blog.framer.website'
url.port = ''
+ if (url.pathname === '' || url.pathname === '/') {
+ url.hostname = 'e2b-landing-page.framer.website'
+ }
+
if (url.pathname === '/blog' || url.pathname === '/blog/') {
url.pathname = '/'
+ url.hostname = 'e2b-blog.framer.website'
+ }
+
+ if (url.pathname.startsWith('/blog')) {
+ url.hostname = 'e2b-blog.framer.website'
+ }
+
+ if (url.pathname === '/changelog' || url.pathname === '/changelog/') {
+ url.pathname = '/'
+ url.hostname = 'e2b-changelog.framer.website'
+ }
+ if (url.pathname.startsWith('/changelog')) {
+ url.hostname = 'e2b-changelog.framer.website'
}
const res = await fetch(url.toString(), { ...req })
const htmlBody = await res.text()
- // Replace has intentionally not completed quotes to catch the rest of the path
- const modifiedHtmlBody = htmlBody.replaceAll(
- 'href="https://e2b-blog.framer.website',
- // The default url on framer do not have /blog in the path but the custom domain does,
- // so we need to handle this explicitly.
- url.pathname === '/' ? 'href="https://e2b.dev/blog' : 'href="https://e2b.dev',
- )
+ // !!! NOTE: Replace has intentionally not completed quotes to catch the rest of the path !!!
+ const modifiedHtmlBody = htmlBody
+ .replaceAll('href="https://e2b-landing-page.framer.website', 'href="https://e2b.dev')
+ .replaceAll(
+ 'href="https://e2b-blog.framer.website',
+ // The default url on framer does not have /blog in the path but the custom domain does,
+ // so we need to handle this explicitly.
+ url.pathname === '/' ? 'href="https://e2b.dev/blog' : 'href="https://e2b.dev',
+ )
+ .replaceAll(
+ 'href="https://e2b-changelog.framer.website',
+ // The default url on framer does not have /changelog in the path but the custom domain does,
+ // so we need to handle this explicitly.
+ url.pathname === '/' ? 'href="https://e2b.dev/changelog' : 'href="https://e2b.dev',
+ )
return new NextResponse(modifiedHtmlBody, {
- ...res,
+ status: res.status,
+ statusText: res.statusText,
+ headers: res.headers,
url: req.url,
})
}
// We should probably filter all /, /blog and /changelog paths here and decide what to do with them in the middleware body.
export const config = {
- matcher: '/blog/:path*',
+ matcher: ['/', '/blog/:path*', '/changelog/:path*'],
}
diff --git a/apps/reverse-proxy/vercel.json b/apps/reverse-proxy/vercel.json
index 6a161ed5d..ab400e06e 100644
--- a/apps/reverse-proxy/vercel.json
+++ b/apps/reverse-proxy/vercel.json
@@ -4,16 +4,6 @@
},
"trailingSlash": false,
"rewrites": [
- {
- "source": "/",
- "destination": "https://e2b-landing-page.framer.website",
- "has": [
- {
- "type": "host",
- "value": "e2b.dev"
- }
- ]
- },
{
"source": "/_vercel/insights/:path*",
"destination": "https://e2b-docs.vercel.app/_vercel/insights/:path*",
@@ -63,16 +53,6 @@
"value": "e2b.dev"
}
]
- },
- {
- "source": "/changelog(\\/)?",
- "destination": "https://e2b-changelog.framer.website",
- "has": [
- {
- "type": "host",
- "value": "e2b.dev"
- }
- ]
}
],
"redirects": [