it's working!!!
This commit is contained in:
@ -3,7 +3,8 @@
|
||||
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const authenticateToken = require('../middleware/authMiddleware'); // Import auth middleware
|
||||
// authenticateToken wird hier für '/' nicht mehr benötigt
|
||||
// const authenticateToken = require('../middleware/authMiddleware');
|
||||
const jwt = require('jsonwebtoken');
|
||||
require('dotenv').config();
|
||||
|
||||
@ -11,6 +12,7 @@ const router = express.Router();
|
||||
const JWT_SECRET = process.env.JWT_SECRET;
|
||||
|
||||
// Helper function to check if a user is already logged in (valid token exists)
|
||||
// Wird für /login und /register verwendet, um eingeloggte User zur Hauptseite umzuleiten
|
||||
const checkAlreadyLoggedIn = (req, res, next) => {
|
||||
const token = req.cookies.token;
|
||||
if (token) {
|
||||
@ -30,10 +32,9 @@ const checkAlreadyLoggedIn = (req, res, next) => {
|
||||
};
|
||||
|
||||
|
||||
// Serve the main todo app page (index.html) - Requires authentication
|
||||
// The authenticateToken middleware will redirect to /login if not authenticated
|
||||
router.get('/', authenticateToken, (req, res) => {
|
||||
// The user is authenticated, serve the main app page
|
||||
// Serve the main todo app page (index.html) - KEINE Authentifizierung mehr hier
|
||||
// Die Seite wird immer geladen. Das Frontend-JS prüft den Login-Status.
|
||||
router.get('/', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '..', 'public', 'index.html'));
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user