Skip to content
Merged
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
Expand Up @@ -164,12 +164,19 @@ private void cleanupServerResources() {
}

private void handleCoordsRequest(HttpExchange exchange) throws IOException {
// Handle CORS preflight request
if (exchange.getRequestMethod().equalsIgnoreCase("OPTIONS")) {
String method = exchange.getRequestMethod();

if (method.equalsIgnoreCase("OPTIONS")) {
sendResponse(exchange, 204, null);
return;
}

if (!method.equalsIgnoreCase("GET")) {
exchange.getResponseHeaders().set("Allow", "GET, OPTIONS");
sendResponse(exchange, 405, "{\"error\": \"Method not allowed\"}");
return;
}

// Check if the client is allowed to access (only localhost)
InetAddress remoteAddress = exchange.getRemoteAddress().getAddress();
if (remoteAddress == null || !remoteAddress.isLoopbackAddress()) {
Expand Down
Loading