Expand the calculator with a multi-step wizard flow, admin dashboard with quote tracking, login/auth system, distance API integration, and history page. Add new UI components (dialog, progress, select, slider, switch), update pricing logic, and improve the overall design with new assets. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
1,007 B
TypeScript
34 lines
1,007 B
TypeScript
import { NextResponse } from "next/server"
|
|
import type { NextRequest } from "next/server"
|
|
|
|
// Routes that require authentication
|
|
const protectedPaths = ["/dashboard", "/historik", "/admin"]
|
|
|
|
export function middleware(request: NextRequest) {
|
|
const { pathname } = request.nextUrl
|
|
|
|
// Check if path requires authentication
|
|
const isProtectedPath = protectedPaths.some((path) => pathname.startsWith(path))
|
|
|
|
if (!isProtectedPath) {
|
|
return NextResponse.next()
|
|
}
|
|
|
|
// Check for session cookie
|
|
const sessionCookie = request.cookies.get("session")
|
|
|
|
if (!sessionCookie?.value) {
|
|
// Redirect to login
|
|
const loginUrl = new URL("/login", request.url)
|
|
loginUrl.searchParams.set("redirect", pathname)
|
|
return NextResponse.redirect(loginUrl)
|
|
}
|
|
|
|
// Cookie exists - let the page validate the session
|
|
// (Session validation happens server-side in the page)
|
|
return NextResponse.next()
|
|
}
|
|
|
|
export const config = {
|
|
matcher: ["/dashboard/:path*", "/historik/:path*", "/admin/:path*"],
|
|
}
|