Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE: Auth: Fix startup error on missing index #758

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
@@ -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
Loading