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
This commit is contained in:
@@ -42,9 +42,12 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
@Override
|
@Override
|
||||||
protected Resource getResource(String resourcePath, Resource location) throws IOException {
|
protected Resource getResource(String resourcePath, Resource location) throws IOException {
|
||||||
Resource resource = location.createRelative(resourcePath);
|
Resource resource = location.createRelative(resourcePath);
|
||||||
return resource.exists() && resource.isReadable()
|
if (resource.exists() && resource.isReadable()) {
|
||||||
? resource
|
return resource;
|
||||||
: new ClassPathResource("/static/index.html");
|
}
|
||||||
|
|
||||||
|
Resource index = new ClassPathResource("/static/index.html");
|
||||||
|
return index.exists() && index.isReadable() ? index : null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user