Skip to content

Commit 8ddda3d

Browse files
authored
BE: Auth: Fix startup error on missing index (#758)
1 parent 1710e2a commit 8ddda3d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/src/main/java/io/kafbat/ui/util/StaticFileWebFilter.java

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.kafbat.ui.util;
22

33
import java.io.IOException;
4+
import lombok.extern.slf4j.Slf4j;
45
import org.jetbrains.annotations.NotNull;
56
import org.springframework.core.io.ClassPathResource;
67
import org.springframework.core.io.buffer.DataBufferFactory;
@@ -15,6 +16,7 @@
1516
import org.springframework.web.server.WebFilterChain;
1617
import reactor.core.publisher.Mono;
1718

19+
@Slf4j
1820
public class StaticFileWebFilter implements WebFilter {
1921

2022
private static final String INDEX_HTML = "/static/index.html";
@@ -29,6 +31,12 @@ public StaticFileWebFilter() {
2931
public StaticFileWebFilter(String path, ClassPathResource resource) {
3032
this.matcher = ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, path);
3133

34+
if (!resource.exists()) {
35+
log.warn("Resource [{}] does not exist. Frontend might not be available.", resource.getPath());
36+
contents = "Missing index.html. Make sure the app has been built with a correct (prod) profile.";
37+
return;
38+
}
39+
3240
try {
3341
this.contents = ResourceUtil.readAsString(resource);
3442
} catch (IOException e) {

0 commit comments

Comments
 (0)