diff --git a/web/src/app/airline/layout.tsx b/web/src/app/airline/layout.tsx new file mode 100644 index 0000000..755ecbf --- /dev/null +++ b/web/src/app/airline/layout.tsx @@ -0,0 +1,4 @@ +import { ReactNode } from 'react'; +export default function AirlineLayout({ children }: { children: ReactNode }) { + return <>{children}; +} diff --git a/web/src/app/airline/page.tsx b/web/src/app/airline/page.tsx new file mode 100644 index 0000000..184d63c --- /dev/null +++ b/web/src/app/airline/page.tsx @@ -0,0 +1,7 @@ +export default function AirlineHome() { + return ( +
+

Airline Mode

+
+ ); +} diff --git a/web/src/app/hotel/layout.tsx b/web/src/app/hotel/layout.tsx new file mode 100644 index 0000000..87d0a21 --- /dev/null +++ b/web/src/app/hotel/layout.tsx @@ -0,0 +1,4 @@ +import { ReactNode } from 'react'; +export default function HotelLayout({ children }: { children: ReactNode }) { + return <>{children}; +} diff --git a/web/src/app/hotel/page.tsx b/web/src/app/hotel/page.tsx new file mode 100644 index 0000000..b9d495c --- /dev/null +++ b/web/src/app/hotel/page.tsx @@ -0,0 +1,7 @@ +export default function HotelHome() { + return ( +
+

Hotel Mode

+
+ ); +} diff --git a/web/src/middleware.ts b/web/src/middleware.ts new file mode 100644 index 0000000..be050cd --- /dev/null +++ b/web/src/middleware.ts @@ -0,0 +1,35 @@ +import { NextRequest, NextResponse } from 'next/server'; + +export function middleware(req: NextRequest) { + const mode = process.env.STORE_MODE; + const { pathname } = req.nextUrl; + + // skip rewrites for api routes, static files, and next internals + if ( + pathname.startsWith('/api') || + pathname.startsWith('/_next') || + pathname.startsWith('/static') || + pathname.includes('.') + // TODO: add robots.txt and sitemap.xml if needed here + ) { + return NextResponse.next(); + } + + // already prefixed with mode + if (pathname.startsWith(`/${mode}`)) { + return NextResponse.next(); + } + + // rewrite root and unprefixed paths to mode-specific route group + const url = req.nextUrl.clone(); + url.pathname = `/${mode}${pathname === '/' ? '' : pathname}`; + + return NextResponse.rewrite(url); +} + +export const config = { + matcher: [ + // match all paths except those starting with _next/static, _next/image, favicon.ico + '/((?!_next/static|_next/image|favicon.ico).*)', + ], +};