feat: implement landing page structure with legal pages, footer, CTA, and domain redirection proxy
This commit is contained in:
33
greenlns-landing/proxy.ts
Normal file
33
greenlns-landing/proxy.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
const APEX_HOST = 'greenlenspro.com'
|
||||
const WWW_HOST = `www.${APEX_HOST}`
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const host = request.headers.get('host')
|
||||
const forwardedProto = request.headers.get('x-forwarded-proto')
|
||||
|
||||
if (!host || (host !== APEX_HOST && host !== WWW_HOST)) {
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
const url = request.nextUrl.clone()
|
||||
let shouldRedirect = false
|
||||
|
||||
if (host === WWW_HOST) {
|
||||
url.host = APEX_HOST
|
||||
shouldRedirect = true
|
||||
}
|
||||
|
||||
if (forwardedProto === 'http' || url.protocol === 'http:') {
|
||||
url.protocol = 'https:'
|
||||
shouldRedirect = true
|
||||
}
|
||||
|
||||
return shouldRedirect ? NextResponse.redirect(url, 308) : NextResponse.next()
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: '/:path*',
|
||||
}
|
||||
Reference in New Issue
Block a user