Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ protected void doFilterInternal(HttpServletRequest request,
auth.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(auth);
}
} else {
// Token present but expired/invalid → 401 so the frontend redirects to login
} else if (request.getRequestURI().startsWith("/api/")) {
// Solo bloquear rutas de API con token expirado; rutas SPA siguen al frontend
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.getWriter().write("{\"error\":\"Token expired or invalid\"}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
@Controller
public class SpaController {

// Forward all non-file, non-API routes to index.html so React Router handles them
// Reenvía rutas SPA (sin extensión de archivo) a index.html para que React Router las maneje.
// Se usan patrones de profundidad fija (hasta 3 niveles) en lugar de /** para no interceptar
// assets estáticos como /static/js/bundle.js cuyos sub-segmentos sí contienen puntos.
@RequestMapping(value = {
"/{path:[^\\.]*}",
"/{path:[^\\.]*}/**"
"/",
"/{p1:[^\\.]*}",
"/{p1:[^\\.]*}/{p2:[^\\.]*}",
"/{p1:[^\\.]*}/{p2:[^\\.]*}/{p3:[^\\.]*}"
})
public String forward() {
return "forward:/index.html";
Expand Down
Loading