From a3add5ded932bf4b9f213649b83854da26f667f3 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 31 Mar 2026 07:09:56 -0400 Subject: [PATCH] fix(webmvc): avoid index fallback exception for missing public routes (#298) Return normal 404 behaviour when static resources are missing in backend only runs, by preventing a fallback to a missing index handler for unresolved routes --- .../src/main/java/org/booklore/config/WebMvcConfig.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/booklore-api/src/main/java/org/booklore/config/WebMvcConfig.java b/booklore-api/src/main/java/org/booklore/config/WebMvcConfig.java index b3cee12a9..8b5960e4f 100644 --- a/booklore-api/src/main/java/org/booklore/config/WebMvcConfig.java +++ b/booklore-api/src/main/java/org/booklore/config/WebMvcConfig.java @@ -42,9 +42,12 @@ public class WebMvcConfig implements WebMvcConfigurer { @Override protected Resource getResource(String resourcePath, Resource location) throws IOException { Resource resource = location.createRelative(resourcePath); - return resource.exists() && resource.isReadable() - ? resource - : new ClassPathResource("/static/index.html"); + if (resource.exists() && resource.isReadable()) { + return resource; + } + + Resource index = new ClassPathResource("/static/index.html"); + return index.exists() && index.isReadable() ? index : null; } }); }