mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-01 03:46:24 +00:00
chore(BE): update response code for docs & signin page (#23140)
This commit is contained in:
parent
29bf750bde
commit
c41828ece0
@ -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)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user