' +
'
Authentication has been configured. The application is restarting to apply changes.
' +
'
⌛
' +
- '
Waiting for the application to come back online...
' +
+ '
Waiting for the new container to come online...
' +
'
';
banner.classList.remove('hidden');
- let attempts = 0;
- const maxAttempts = 120; // 10 min at 5s intervals
+ // Poll /api/setup/status — once the new container comes online with EasyAuth
+ // configured, isEasyAuthConfigured will be true and setup mode will no longer
+ // be active. At that point redirect to / and let the app take over.
const pollInterval = 5000;
-
const pollRestart = async () => {
- attempts++;
- const statusEl = document.getElementById('restart-status');
try {
- const res = await fetch('/api/setup/health', { cache: 'no-store' });
+ const res = await fetch('/api/setup/status', { cache: 'no-store' });
if (res.ok) {
const data = await res.json();
- if (data.ready) {
- statusEl.textContent = 'Application is ready! Redirecting...';
+ if (data.isEasyAuthConfigured && !data.isSetupCompleted) {
+ // New container is online with EasyAuth active — redirect to app
+ document.getElementById('restart-status').textContent = 'Application is ready!';
document.getElementById('restart-spinner').textContent = '\u2705';
- setTimeout(() => window.location.href = '/', 1500);
+ setTimeout(() => window.location.href = '/', 1000);
return;
}
+ // Still on the old container (isSetupCompleted=true) — keep waiting
+ document.getElementById('restart-status').textContent = 'Auth configured, waiting for container restart...';
}
} catch (e) {
- // App still restarting — expected
- }
- if (attempts >= maxAttempts) {
- statusEl.textContent = 'The application is taking longer than expected. Try refreshing the page manually.';
- document.getElementById('restart-spinner').textContent = '\u26A0\uFE0F';
- return;
+ // Container is cycling — expected during restart
+ document.getElementById('restart-status').textContent = 'Container restarting...';
}
- statusEl.textContent = 'Waiting for the application to come back online... (' + attempts + ')';
setTimeout(pollRestart, pollInterval);
};
- // Start polling after a short delay to let the restart begin
- setTimeout(pollRestart, 8000);
+ setTimeout(pollRestart, 5000);
}