mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 20:08:14 +00:00
516de6ad60
New chrome-less (portal) route group with /portal/[clinic], a card-style choice of "Book an appointment" vs "View my results", and step flows wired to a new public backend router (src/routes/portal.ts): - GET /api/portal/:clinic -> clinic name - POST /api/portal/:clinic/appointments (verifies name+file#, books a confirmed appointment that appears on the doctor's Appointments page) - GET /api/portal/:clinic/results (minimal, safe status — no clinical values) Excluded /portal from the auth proxy redirect so the kiosk loads without a session. PHI exposure is intentionally minimal (see docs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
// Better Auth session cookie names (plain in dev, __Secure- prefixed over
|
|
// HTTPS). The authoritative check happens client-side (AppAuthGuard) and on the
|
|
// API; this is an optimistic redirect to avoid flashing the app when clearly
|
|
// signed out.
|
|
const SESSION_COOKIES = [
|
|
"better-auth.session_token",
|
|
"__Secure-better-auth.session_token",
|
|
];
|
|
|
|
export function proxy(request: NextRequest) {
|
|
const hasSession = SESSION_COOKIES.some((name) =>
|
|
request.cookies.has(name),
|
|
);
|
|
|
|
if (!hasSession) {
|
|
const url = request.nextUrl.clone();
|
|
url.pathname = "/login";
|
|
url.search = "";
|
|
return NextResponse.redirect(url);
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
// Run on all routes except the auth pages, Next internals and static assets.
|
|
matcher: [
|
|
"/((?!login|signup|verify-email|forgot-password|reset-password|onboarding|accept-invite|portal|_next/static|_next/image|favicon.ico|temetro-logo.png|avatars).*)",
|
|
],
|
|
};
|