fix: keep /admin reachable while setup is required (#392)

The root layout replaced the entire app with the SetupScreen whenever
the config was incomplete (missing gallery.yaml or Immich credentials)
— including /admin, which lives under the same root layout. That locked
users out of the very tool that fixes an incomplete configuration.

The middleware now forwards the request pathname via an x-pathname
header, and the root layout skips the setup screen for admin paths, so
/admin renders normally (login when ADMIN_PASSWORD is set, the
enable-hint otherwise) while every other route keeps showing the setup
instructions.

Fixes #326

Co-authored-by: ralksta <ralksta@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Ralksta
2026-08-05 00:27:09 +02:00
committed by GitHub
parent f03011e0ec
commit 8f0bb94caf
4 changed files with 49 additions and 2 deletions

View File

@@ -23,6 +23,9 @@ export function middleware(request: NextRequest) {
const requestHeaders = new Headers(request.headers);
requestHeaders.set('x-nonce', nonce);
// Layouts cannot read the request URL; the root layout needs the pathname
// to keep /admin reachable while the app is in setup mode.
requestHeaders.set('x-pathname', request.nextUrl.pathname);
requestHeaders.set('Content-Security-Policy', cspDirectives);
const response = NextResponse.next({