Fix setup check to redirect when members table doesn't exist
Build and Push Docker Image / build (push) Successful in 1m49s Details

- Treat "table does not exist" errors as needing setup
- Redirect to /setup on unexpected errors (safer default)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt 2026-01-26 09:55:37 +01:00
parent cd60c8ba32
commit e4a40e1e40
1 changed files with 12 additions and 1 deletions

View File

@ -103,7 +103,16 @@ const setupCheckHandle: Handle = async ({ event, resolve }) => {
if (error) {
console.error('Error checking for existing users:', error);
// On error, continue without redirect (fail open)
// If table doesn't exist or other DB error, assume setup is needed
// Common errors: relation "members" does not exist, permission denied
if (error.message?.includes('does not exist') ||
error.message?.includes('relation') ||
error.code === '42P01' || // undefined_table
error.code === 'PGRST204') { // no rows (table might not exist)
setupCheckCache = { needsSetup: true, checkedAt: now };
throw redirect(303, '/setup');
}
// For other errors, fail open to avoid blocking the app
return resolve(event);
}
@ -119,6 +128,8 @@ const setupCheckHandle: Handle = async ({ event, resolve }) => {
throw err;
}
console.error('Error in setup check:', err);
// On unexpected errors, redirect to setup as a safe default
throw redirect(303, '/setup');
}
return resolve(event);