fix first online resevation

This commit is contained in:
root
2026-05-09 20:01:51 -04:00
parent c4a45c8b21
commit 09b0e3b55f
75 changed files with 6394 additions and 2190 deletions
+19 -14
View File
@@ -1,21 +1,26 @@
import { NextResponse } from 'next/server'
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'
import { clerkMiddlewareEnabled } from '@/lib/clerk'
import type { NextRequest } from 'next/server'
const isProtectedRoute = createRouteMatcher([
'/dashboard(.*)',
'/onboarding(.*)',
])
function isProtectedRoute(req: NextRequest) {
return req.nextUrl.pathname === '/dashboard' || req.nextUrl.pathname.startsWith('/dashboard/')
}
export default clerkMiddlewareEnabled
? clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) {
auth().protect()
}
})
: function middleware() {
return NextResponse.next()
function localJwtMiddleware(req: NextRequest): NextResponse {
if (!isProtectedRoute(req)) return NextResponse.next()
// Check for employee_token cookie (set on login) OR allow if coming from sign-in
const token = req.cookies.get('employee_token')?.value
if (!token) {
const signInUrl = new URL('/sign-in', req.url)
signInUrl.searchParams.set('redirect', req.nextUrl.pathname)
return NextResponse.redirect(signInUrl)
}
return NextResponse.next()
}
export default function middleware(req: NextRequest) {
return localJwtMiddleware(req)
}
export const config = {
matcher: [