tracks/internal/middleware
Claude db538f6dee
Fix authentication: redirect to login page instead of showing JSON errors
The auth middleware was returning JSON error messages ("No authentication token
provided") for web UI requests, which displayed as plain text in the browser.

Changes:
- Added isAPIRequest check to detect if request is for /api/* or web UI
- For web UI requests without auth: redirect to /login (HTTP 302)
- For API requests without auth: return JSON error (HTTP 401)
- Applied same logic for all auth failure scenarios (no token, invalid token,
  invalid claims, user not found)

This fixes the issue where users see JSON errors in the browser instead of
being properly redirected to the login page when authentication fails.
2025-11-05 13:26:24 +00:00
..
auth.go Fix authentication: redirect to login page instead of showing JSON errors 2025-11-05 13:26:24 +00:00