|
@@ -174,6 +174,21 @@ static const httpd_uri_t wakeup_delete = {
|
|
|
.handler = wakeup_delete_handler
|
|
|
};
|
|
|
|
|
|
+static esp_err_t wakeup_options_handler(httpd_req_t *req) {
|
|
|
+ httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
|
|
+ httpd_resp_set_hdr(req, "Access-Control-Allow-Methods", "GET, PUT, DELETE, OPTIONS");
|
|
|
+ httpd_resp_set_hdr(req, "Access-Control-Max-Age", "86400");
|
|
|
+ httpd_resp_set_hdr(req, "Access-Control-Allow-Headers", "Content-Type");
|
|
|
+ httpd_resp_sendstr(req, "");
|
|
|
+ return ESP_OK;
|
|
|
+}
|
|
|
+
|
|
|
+static const httpd_uri_t wakeup_options = {
|
|
|
+ .uri = "/v1/wakeup/*",
|
|
|
+ .method = HTTP_OPTIONS,
|
|
|
+ .handler = wakeup_options_handler
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
httpd_handle_t start_webserver(TaskHandle_t* task_handle) {
|
|
|
httpd_handle_t server;
|
|
@@ -190,6 +205,7 @@ httpd_handle_t start_webserver(TaskHandle_t* task_handle) {
|
|
|
httpd_register_uri_handler(server, &wakeup_get);
|
|
|
httpd_register_uri_handler(server, &wakeup_put);
|
|
|
httpd_register_uri_handler(server, &wakeup_delete);
|
|
|
+ httpd_register_uri_handler(server, &wakeup_options);
|
|
|
return server;
|
|
|
}
|
|
|
|