You should not make POST request in your browser using a URL directly. Browser can only make GET requests when you enter a URL in the address bar. And since your endpoint is mapped to @PostMapping and you are sending a GET the server responds with a 405 method not allowed error.
You can either change the mapping to @GetMapping or keep the @PostMapping and call it with JavaScript fetch API or with Postman as mentioned in previous answers or curl:
curl -X POST http://localhost:8080/api/command/on