<?php

use Illuminate\Support\Facades\Route;

/**
 * The SPA shell, built by `npm run build:deploy` in /web and copied here as
 * resources/views/spa.blade.php per docs/01-architecture.md §Frontend/
 * backend integration. A catch-all keeps this working for client-side
 * routes (e.g. a hard refresh on /members/42) — anything that isn't
 * /api/*, /sanctum/*, or the health check falls through to the SPA, which
 * then resolves the path itself via React Router.
 */
Route::get('/{any?}', function () {
    if (! view()->exists('spa')) {
        return response(
            'Frontend build not found. Run `npm run build:deploy` in /web (see docs/01-architecture.md).',
            503,
        );
    }

    return view('spa');
})->where('any', '^(?!api/|sanctum/|up$).*$');
