Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert root route traffic to the new landing page #495

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/src/app/hostnames.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// We are in the process of migrating to the new landing page hosting.
export const landingPageWebflowHostname = 'e2b-dev.webflow.io'
export const landingPageHostname = 'e2b-landing-page.com'
export const landingPageFramerHostname = 'e2b-landing-page.framer.website'
export const blogFramerHostname = 'e2b-blog.framer.website'
export const changelogFramerHostname = 'e2b-changelog.framer.website'
16 changes: 6 additions & 10 deletions apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from 'next/server'
import { replaceUrls } from '@/utils/replaceUrls'
import {
landingPageWebflowHostname,
landingPageHostname,
landingPageFramerHostname,
blogFramerHostname,
changelogFramerHostname,
Expand All @@ -17,22 +17,22 @@ export async function middleware(req: NextRequest): Promise<NextResponse> {

if (url.pathname === '' || url.pathname === '/') {
if (process.env.NODE_ENV === 'production') {
url.hostname = landingPageWebflowHostname
url.hostname = landingPageHostname
} else {
return NextResponse.redirect(new URL('/dashboard', req.url))
}
}

if (url.pathname.startsWith('/terms')) {
url.hostname = landingPageWebflowHostname
url.hostname = landingPageHostname
}

if (url.pathname.startsWith('/privacy')) {
url.hostname = landingPageWebflowHostname
url.hostname = landingPageHostname
}

if (url.pathname.startsWith('/pricing')) {
url.hostname = landingPageWebflowHostname
url.hostname = landingPageHostname
}

// TODO: Not on the new landing page hosting yet
Expand Down Expand Up @@ -62,12 +62,8 @@ export async function middleware(req: NextRequest): Promise<NextResponse> {

// !!! NOTE: Replace has intentionally not completed quotes to catch the rest of the path !!!
const modifiedHtmlBody = replaceUrls(htmlBody, url.pathname, 'href="', '">')
// Even though we are paying for a Webflow tier that allows us to remove the badge, it doesn't work.
// eslint-disable-next-line
const scriptRegex = /<script src="https:\/\/cdn\.prod\.website-files\.com\/[^\"]*\.js" type="text\/javascript"><\/script>/g
const cleanedHtmlBody = modifiedHtmlBody.replace(scriptRegex, '')

return new NextResponse(cleanedHtmlBody, {
return new NextResponse(modifiedHtmlBody, {
status: res.status,
statusText: res.statusText,
headers: res.headers,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/utils/replaceUrls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
landingPageWebflowHostname,
landingPageHostname,
landingPageFramerHostname,
blogFramerHostname,
changelogFramerHostname,
Expand All @@ -13,7 +13,7 @@ export function replaceUrls(text: string, urlPathName: string, prefix: string =
(_, url) => url + suffix,
)
.replaceAll(
`${prefix}${landingPageWebflowHostname}`,
`${prefix}${landingPageHostname}`,
`${prefix}https://e2b.dev`
)
.replaceAll(
Expand Down
Loading