Merge branch 'main' into feature/custom-workflows

This commit is contained in:
Ram Narayan Balaji 2025-08-29 13:28:50 +05:30 committed by GitHub
commit fdacf4a32f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,15 +21,19 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import org.jetbrains.annotations.Nullable;
import org.openmetadata.service.config.OMWebConfiguration;
import org.openmetadata.service.resources.system.IndexResource;
public class OpenMetadataAssetServlet extends AssetServlet {
private final OMWebConfiguration webConfiguration;
private final String basePath;
// List of frontend paths that should be whitelisted and serve the index file
private static final List<String> WHITELISTED_PATHS = Arrays.asList("/docs", "/signin");
public OpenMetadataAssetServlet(
String basePath,
String resourcePath,
@ -57,8 +61,31 @@ public class OpenMetadataAssetServlet extends AssetServlet {
}
super.doGet(req, resp);
// Check if response is 404 and the path should be whitelisted
if (!resp.isCommitted() && (resp.getStatus() == 404)) {
resp.sendError(404);
if (isWhitelistedPath(requestUri)) {
// Serve index file for whitelisted paths instead of 404
resp.setStatus(200);
resp.setContentType("text/html");
resp.getWriter().write(IndexResource.getIndexFile(this.basePath));
} else {
resp.sendError(404);
}
}
}
/**
* Check if the given URI path should be whitelisted
* @param requestUri The request URI to check
* @return true if the path should be whitelisted, false otherwise
*/
private boolean isWhitelistedPath(String requestUri) {
for (String whitelistedPath : WHITELISTED_PATHS) {
if (requestUri.startsWith(whitelistedPath)) {
return true;
}
}
return false;
}
}