Skip to content
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
36 changes: 26 additions & 10 deletions src/app/maintenance/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import Layout from '@/components/Global/Layout'
'use client'
import chillPeanutAnim from '@/animations/GIF_ALPHA_BACKGORUND/512X512_ALPHA_GIF_konradurban_01.gif'
import { Button } from '@/components/0_Bruddle'
import Image from 'next/image'
import { useRouter } from 'next/navigation'

export default function MaintenancePage() {
const MaintenancePage = () => {
const router = useRouter()
return (
<Layout>
<div className="flex min-h-screen flex-col items-center justify-center">
<h1 className="mb-4 text-4xl font-bold">Under Maintenance</h1>
<p className="text-xl">
This feature is currently undergoing maintenance. We apologize for the inconvenience.
</p>
</div>
</Layout>
<div className="flex h-screen flex-col items-center justify-center gap-4 p-6">
<Image src={chillPeanutAnim.src} alt="Maintenance" width={250} height={250} />
<h1 className="text-3xl font-bold text-black">Under Maintenance</h1>
<p className="text-center text-lg text-gray-1">
We are currently going through maintenance. We should be back online shortly. Sorry for the
inconvenience.
</p>
<p className="text-center text-gray-1">Thank you for your patience.</p>

<Button
variant="transparent"
onClick={() => router.push('/support')}
className="h-5 w-fit p-0 underline underline-offset-2"
>
Contact Support?
</Button>
</div>
)
}

export default MaintenancePage
7 changes: 4 additions & 3 deletions src/components/Global/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client'

import { Banner } from '@/components/Global/Banner'
import Footer from '@/components/Global/Footer'
import { GenericBanner } from '@/components/Global/Banner'
import { ThemeProvider } from '@/config'
import { useFooterVisibility } from '@/context/footerVisibility'
import { Widget } from '@typeform/embed-react'
Expand Down Expand Up @@ -39,7 +38,9 @@ const Layout = ({ children, className }: LayoutProps) => {
<ThemeProvider>
<div className="relative">
<div className="flex min-h-screen flex-col ">
<Banner />
{/* <Banner /> */}
{/* @dev note: temp, remove banner later */}
<GenericBanner message="Under maintenance" icon="⚠️" />
<div className="flex grow justify-center">
<div
className={`4xl:max-w-full flex grow flex-col justify-center pb-2 pt-6 sm:mx-auto sm:px-16 md:px-5 lg:px-6 2xl:px-8 ${className}`}
Expand Down
38 changes: 37 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
import { NextResponse } from 'next/server'

export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl
const maintenanceMode = true

if (maintenanceMode) {
const allowedPaths = ['/', '/maintenance', '/apple-app-site-association']
if (
!allowedPaths.includes(pathname) &&
!pathname.startsWith('/api/') &&
!pathname.startsWith('/_next/') &&
!pathname.startsWith('/.well-known/') &&
!pathname.match(
/.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
)
) {
return NextResponse.redirect(new URL('/maintenance', request.url))
}
}
Comment on lines +6 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Hard-coded maintenance mode will lock users out

Shipping with maintenanceMode = true redirects nearly all traffic. Read from an env var and allow support access.

Apply this diff:

-    const { pathname } = request.nextUrl
-    const maintenanceMode = true
+    const { pathname } = request.nextUrl
+    const maintenanceMode =
+        (process.env.NEXT_PUBLIC_MAINTENANCE_MODE || process.env.MAINTENANCE_MODE) === 'true'
@@
-        const allowedPaths = ['/', '/maintenance', '/apple-app-site-association']
+        const allowedPaths = ['/', '/maintenance', '/support', '/apple-app-site-association']
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { pathname } = request.nextUrl
const maintenanceMode = true
if (maintenanceMode) {
const allowedPaths = ['/', '/maintenance', '/apple-app-site-association']
if (
!allowedPaths.includes(pathname) &&
!pathname.startsWith('/api/') &&
!pathname.startsWith('/_next/') &&
!pathname.startsWith('/.well-known/') &&
!pathname.match(
/.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
)
) {
return NextResponse.redirect(new URL('/maintenance', request.url))
}
}
const { pathname } = request.nextUrl
const maintenanceMode =
(process.env.NEXT_PUBLIC_MAINTENANCE_MODE || process.env.MAINTENANCE_MODE) === 'true'
if (maintenanceMode) {
const allowedPaths = ['/', '/maintenance', '/support', '/apple-app-site-association']
if (
!allowedPaths.includes(pathname) &&
!pathname.startsWith('/api/') &&
!pathname.startsWith('/_next/') &&
!pathname.startsWith('/.well-known/') &&
!pathname.match(
/.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
)
) {
return NextResponse.redirect(new URL('/maintenance', request.url))
}
}
🧰 Tools
🪛 GitHub Check: CodeQL

[failure] 16-18: Polynomial regular expression used on uncontrolled data
This regular expression that depends on a user-provided value may run slow on strings with many repetitions of 'a'.


const url = request.nextUrl.clone()
const promoList: { [key: string]: string } = JSON.parse(process.env.PROMO_LIST ?? '{}')

Expand Down Expand Up @@ -46,5 +64,23 @@

// Updated matcher to include root path
export const config = {
matcher: ['/', '/claim/:path*', '/api/:path*'],
matcher: [
'/',
'/home',
'/claim/:path*',
'/api/:path*',
'/home/:path*',
'/profile/:path*',
'/send/:path*',
'/request/:path*',
'/settings/:path*',
'/setup/:path*',
'/share/:path*',
'/history/:path*',
'/raffle/:path*',
'/c/:path*',
'/pay/:path*',
'/p/:path*',
'/link/:path*',
],
}
Loading