Skip to content

Commit

Permalink
Revert root route traffic to the new landing page (#495)
Browse files Browse the repository at this point in the history
This PR fixes what #493 messed up
  • Loading branch information
mlejva authored Dec 6, 2024
2 parents b416c63 + 593f58b commit 7881b52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
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

0 comments on commit 7881b52

Please sign in to comment.