From 18799d894619683cbffbbd140648737abd8b4cc5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Aug 2022 21:47:07 -0700 Subject: Handle API 404 errors --- src/main/java/org/traccar/web/WebServer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java index 704a4b3cd..62ac338eb 100644 --- a/src/main/java/org/traccar/web/WebServer.java +++ b/src/main/java/org/traccar/web/WebServer.java @@ -106,7 +106,8 @@ public class WebServer implements LifecycleObject { protected void handleErrorPage( HttpServletRequest request, Writer writer, int code, String message) throws IOException { Path index = Paths.get(config.getString(Keys.WEB_PATH), "index.html"); - if (code == HttpStatus.NOT_FOUND_404 && Files.exists(index)) { + if (code == HttpStatus.NOT_FOUND_404 + && !request.getPathInfo().startsWith("/api/") && Files.exists(index)) { writer.write(Files.readString(index)); } else { writer.write("Error" -- cgit v1.2.3