Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix non default link urls

Tomas Valenta39f0863b7b45
diff --git a/apps/reverse-proxy/middleware.ts b/apps/reverse-proxy/middleware.ts
index 621ae1093..978cd4f2e 100644
--- a/apps/reverse-proxy/middleware.ts
+++ b/apps/reverse-proxy/middleware.ts
@@ -9,20 +9,20 @@ export async function middleware(req: NextRequest): Promise<NextResponse> {
url.hostname = 'e2b-blog.framer.website'
url.port = ''
- if (url.pathname === '/blog') {
+ if (url.pathname === '/blog' || url.pathname === '/blog/') {
url.pathname = '/'
}
- console.log(url.toString())
-
const res = await fetch(url.toString(), { ...req })
const htmlBody = await res.text()
- // Replace has intentionally not compelted quotes to catch the rest of the path
+ // Replace has intentionally not completed quotes to catch the rest of the path
const modifiedHtmlBody = htmlBody.replaceAll(
'href="https://e2b-blog.framer.website',
- 'href="https://e2b.dev/blog',
+ // 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',
)
return new NextResponse(modifiedHtmlBody, res)