Skip to content

Commit

Permalink
BE: Auth: Fix startup error on missing (non-prod profile) index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Haarolean committed Jan 9, 2025
1 parent 1710e2a commit 227043b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/src/main/java/io/kafbat/ui/util/StaticFileWebFilter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.kafbat.ui.util;

import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.buffer.DataBufferFactory;
Expand All @@ -15,6 +16,7 @@
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

@Slf4j
public class StaticFileWebFilter implements WebFilter {

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

if (!resource.exists()) {
log.warn("Resource [{}] does not exist. Frontend might not be available.", resource.getPath());
contents = "Missing index.html. Make sure the app has been built with a correct (prod) profile.";
return;
}

try {
this.contents = ResourceUtil.readAsString(resource);
} catch (IOException e) {
Expand Down

0 comments on commit 227043b

Please sign in to comment.