fix: Update authentication callback to return HTML with client-side redirect for SPA compatibility
This commit is contained in:
parent
9f7aa99320
commit
b8a6a52417
|
|
@ -100,8 +100,61 @@ export default defineEventHandler(async (event) => {
|
||||||
console.log(`[KEYCLOAK] Authentication completed successfully in ${totalDuration}ms`)
|
console.log(`[KEYCLOAK] Authentication completed successfully in ${totalDuration}ms`)
|
||||||
console.log('[KEYCLOAK] Session cookie set, redirecting to dashboard...')
|
console.log('[KEYCLOAK] Session cookie set, redirecting to dashboard...')
|
||||||
|
|
||||||
// Redirect to dashboard
|
// Return HTML with client-side redirect for SPA compatibility
|
||||||
await sendRedirect(event, '/dashboard')
|
setHeader(event, 'Content-Type', 'text/html')
|
||||||
|
return `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Authentication Successful - Port Nimara Portal</title>
|
||||||
|
<meta http-equiv="refresh" content="0;url=/dashboard">
|
||||||
|
<script>
|
||||||
|
// Immediate redirect
|
||||||
|
window.location.href = '/dashboard';
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background: linear-gradient(135deg, #387bca 0%, #2c5aa0 100%);
|
||||||
|
color: white;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 10px;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
.spinner {
|
||||||
|
border: 3px solid rgba(255, 255, 255, 0.3);
|
||||||
|
border-top: 3px solid white;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
margin: 1rem auto;
|
||||||
|
}
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="spinner"></div>
|
||||||
|
<h2>Authentication successful!</h2>
|
||||||
|
<p>Redirecting to dashboard...</p>
|
||||||
|
<p><small>If you are not redirected automatically, <a href="/dashboard" style="color: #ffffff;">click here</a>.</small></p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
const duration = Date.now() - startTime
|
const duration = Date.now() - startTime
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue