File tree Expand file tree Collapse file tree
src/client/java/fr/sukikui/playercoordsapi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,12 +164,19 @@ private void cleanupServerResources() {
164164 }
165165
166166 private void handleCoordsRequest (HttpExchange exchange ) throws IOException {
167- // Handle CORS preflight request
168- if (exchange .getRequestMethod ().equalsIgnoreCase ("OPTIONS" )) {
167+ String method = exchange .getRequestMethod ();
168+
169+ if (method .equalsIgnoreCase ("OPTIONS" )) {
169170 sendResponse (exchange , 204 , null );
170171 return ;
171172 }
172173
174+ if (!method .equalsIgnoreCase ("GET" )) {
175+ exchange .getResponseHeaders ().set ("Allow" , "GET, OPTIONS" );
176+ sendResponse (exchange , 405 , "{\" error\" : \" Method not allowed\" }" );
177+ return ;
178+ }
179+
173180 // Check if the client is allowed to access (only localhost)
174181 InetAddress remoteAddress = exchange .getRemoteAddress ().getAddress ();
175182 if (remoteAddress == null || !remoteAddress .isLoopbackAddress ()) {
You can’t perform that action at this time.
0 commit comments