This commit is contained in:
BRanulf 2025-06-23 14:04:22 +08:00
parent c3e4a1b483
commit e5eca44059

View File

@ -48,7 +48,7 @@ public class WebServer {
Map.entry("woff2", "application/font-woff2"), Map.entry("woff2", "application/font-woff2"),
Map.entry("ttf", "application/font-sfnt"), Map.entry("ttf", "application/font-sfnt"),
Map.entry("eot", "application/vnd.ms-fontobject"), Map.entry("eot", "application/vnd.ms-fontobject"),
Map.entry("ico", "image/x-icon") // 添加 favicon.ico Map.entry("ico", "image/x-icon")
); );
public WebServer(PlayerTimeTracker timeTracker, int port, MinecraftServer minecraftServer) throws IOException { public WebServer(PlayerTimeTracker timeTracker, int port, MinecraftServer minecraftServer) throws IOException {
@ -67,7 +67,7 @@ public class WebServer {
server.createContext("/api/stats", exchange -> { server.createContext("/api/stats", exchange -> {
handleCors(exchange); handleCors(exchange);
if ("OPTIONS".equals(exchange.getRequestMethod())) { if ("OPTIONS".equals(exchange.getRequestMethod())) {
exchange.sendResponseHeaders(204, -1); // CORS 预检请求 exchange.sendResponseHeaders(204, -1);
return; return;
} }