added suspend
This commit is contained in:
@@ -4,6 +4,8 @@ import { Footer } from '@/components/layout/footer'
|
||||
import MobileTabBar from '@/components/layout/MobileTabBar'
|
||||
import CTA from '@/components/sections/cta'
|
||||
import UpdateNotification from '@/components/UpdateNotification'
|
||||
import PWAInstallPrompt, { IOSInstallPrompt } from '@/components/PWAInstallPrompt'
|
||||
import ClientFloatingWhatsApp from '@/components/ClientFloatingWhatsApp'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Padmaaja Rasooi - Premium Food Products | Multigrain Flour & Rice',
|
||||
@@ -27,6 +29,14 @@ export default async function RootLayout({
|
||||
|
||||
{/* PWA Update Notification */}
|
||||
<UpdateNotification />
|
||||
<PWAInstallPrompt />
|
||||
<IOSInstallPrompt />
|
||||
<ClientFloatingWhatsApp
|
||||
phoneNumber="+919475758817"
|
||||
message="Hello! I'm interested in Padmaaja Rasooi products. Can you help me?"
|
||||
position="bottom-right"
|
||||
showTooltip={true}
|
||||
/>
|
||||
|
||||
{/* Mobile Tab Bar */}
|
||||
<MobileTabBar />
|
||||
|
||||
@@ -6,8 +6,7 @@ import { Toaster } from '@/components/ui/sonner'
|
||||
import { auth } from '@/auth';
|
||||
import StructuredData from '@/components/StructuredData'
|
||||
import { generateOrganizationJsonLd } from '@/lib/structured-data'
|
||||
import PWAInstallPrompt, { IOSInstallPrompt } from '@/components/PWAInstallPrompt'
|
||||
import ClientFloatingWhatsApp from '@/components/ClientFloatingWhatsApp'
|
||||
|
||||
|
||||
// Optimize font loading
|
||||
const inter = Inter({
|
||||
@@ -230,14 +229,7 @@ export default async function PublicRootLayout({
|
||||
</footer>
|
||||
|
||||
<Toaster />
|
||||
<PWAInstallPrompt />
|
||||
<IOSInstallPrompt />
|
||||
<ClientFloatingWhatsApp
|
||||
phoneNumber="+919475758817"
|
||||
message="Hello! I'm interested in Padmaaja Rasooi products. Can you help me?"
|
||||
position="bottom-right"
|
||||
showTooltip={true}
|
||||
/>
|
||||
|
||||
</Providers>
|
||||
</div>
|
||||
|
||||
|
||||
18
app/suspended/layout.tsx
Normal file
18
app/suspended/layout.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Website Temporarily Suspended',
|
||||
description: 'This website is temporarily unavailable due to pending maintenance dues.'
|
||||
}
|
||||
|
||||
export default function SuspendedLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-b from-amber-50 via-white to-slate-50">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
20
app/suspended/page.tsx
Normal file
20
app/suspended/page.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
export default function SuspendedPage() {
|
||||
return (
|
||||
<main className="mx-auto flex min-h-screen max-w-3xl items-center px-6 py-16">
|
||||
<div className="w-full rounded-2xl border border-amber-200 bg-white/80 p-8 shadow-[0_20px_60px_-25px_rgba(15,23,42,0.35)] backdrop-blur sm:p-12">
|
||||
<div className="inline-flex items-center rounded-full border border-amber-200 bg-amber-50 px-4 py-1 text-xs font-semibold uppercase tracking-[0.2em] text-amber-700">
|
||||
Service Notice
|
||||
</div>
|
||||
<h1 className="mt-6 text-3xl font-semibold text-slate-900 sm:text-4xl">
|
||||
Website Temporarily Suspended
|
||||
</h1>
|
||||
<p className="mt-4 text-base leading-7 text-slate-700">
|
||||
This website is temporarily unavailable due to pending maintenance dues.
|
||||
</p>
|
||||
<p className="mt-3 text-base leading-7 text-slate-700">
|
||||
Please contact the administrator to restore services.
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
54
proxy.ts
54
proxy.ts
@@ -1,56 +1,26 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import type { NextRequest } from 'next/server'
|
||||
|
||||
export default async function proxy(request: NextRequest) {
|
||||
export function proxy(request: NextRequest) {
|
||||
const isSuspended = process.env.SITE_SUSPENDED === 'true'
|
||||
|
||||
// Fast path: do nothing if the site is not suspended.
|
||||
if (!isSuspended) {
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
const { pathname } = request.nextUrl
|
||||
|
||||
// Skip middleware for admin routes, API routes, and static files
|
||||
if (pathname.startsWith('/admin') ||
|
||||
pathname.startsWith('/api') ||
|
||||
pathname.startsWith('/_next') ||
|
||||
pathname === '/favicon.ico') {
|
||||
// Allow access to the suspended page itself.
|
||||
if (pathname === '/suspended') {
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
// Check if maintenance mode is enabled via API
|
||||
try {
|
||||
const maintenanceResponse = await fetch(new URL('/api/maintenance-check', request.url), {
|
||||
headers: {
|
||||
// Forward cookies to maintain session for admin check
|
||||
cookie: request.headers.get('cookie') || ''
|
||||
}
|
||||
})
|
||||
|
||||
if (maintenanceResponse.ok) {
|
||||
const { maintenanceMode } = await maintenanceResponse.json()
|
||||
|
||||
// If maintenance mode is ON and user is not on maintenance page
|
||||
if (maintenanceMode && pathname !== '/maintenance') {
|
||||
return NextResponse.redirect(new URL('/maintenance', request.url))
|
||||
}
|
||||
|
||||
// If maintenance mode is OFF and user is on maintenance page
|
||||
if (!maintenanceMode && pathname === '/maintenance') {
|
||||
return NextResponse.redirect(new URL('/', request.url))
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Middleware error:', error)
|
||||
// If maintenance check fails, allow the request to continue
|
||||
}
|
||||
|
||||
return NextResponse.next()
|
||||
return NextResponse.redirect(new URL('/suspended', request.url))
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
/*
|
||||
* Match all request paths except for the ones starting with:
|
||||
* - api (API routes)
|
||||
* - _next/static (static files)
|
||||
* - _next/image (image optimization files)
|
||||
* - favicon.ico (favicon file)
|
||||
*/
|
||||
'/((?!api|_next/static|_next/image|favicon.ico).*)',
|
||||
'/((?!_next/static|_next/image|favicon.ico|suspended).*)',
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user