Initialize Nuxt.js project with Docker deployment setup
- Add core Nuxt.js application structure with TypeScript - Include Docker configuration and deployment guide - Set up project scaffolding with pages, composables, and middleware - Add environment configuration and Git ignore rules
This commit is contained in:
17
middleware/auth.ts
Normal file
17
middleware/auth.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export default defineNuxtRouteMiddleware((to) => {
|
||||
// Skip auth for public pages
|
||||
if (to.meta.auth === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if user is authenticated
|
||||
const authState = useState('auth.state', () => ({
|
||||
authenticated: false,
|
||||
user: null,
|
||||
groups: [],
|
||||
}));
|
||||
|
||||
if (!authState.value.authenticated) {
|
||||
return navigateTo('/login');
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user