Login resuelto
This commit is contained in:
@@ -4,13 +4,25 @@
|
||||
import Toast from '$lib/components/Toast.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { auth } from '$lib/stores/auth.js';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { browser } from '$app/environment';
|
||||
import '../app.css';
|
||||
|
||||
let mounted = false;
|
||||
|
||||
onMount(() => {
|
||||
auth.init();
|
||||
mounted = true;
|
||||
});
|
||||
|
||||
// Guard reactivo global: redirige a /login si no está autenticado en rutas protegidas
|
||||
$: if (browser && mounted && !$auth.isAuthenticated &&
|
||||
!$page.url.pathname.startsWith('/login') &&
|
||||
!$page.url.pathname.startsWith('/register')) {
|
||||
goto('/login');
|
||||
}
|
||||
|
||||
$: showHeader = !$page.url.pathname.startsWith('/login') && !$page.url.pathname.startsWith('/register');
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,6 +10,16 @@ export default defineConfig({
|
||||
usePolling: true,
|
||||
interval: 500
|
||||
},
|
||||
// HMR: el browser llega al contenedor en el mismo puerto 3000
|
||||
hmr: {
|
||||
host: 'localhost',
|
||||
clientPort: parseInt(process.env.HMR_CLIENT_PORT || '3000')
|
||||
},
|
||||
// Permitir que Vite sirva archivos del filesystem del contenedor
|
||||
fs: {
|
||||
allow: ['/app', '.'],
|
||||
strict: false
|
||||
},
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.PUBLIC_API_URL || 'http://localhost:8000',
|
||||
|
||||
Reference in New Issue
Block a user