diff --git a/esphome/components/web_server/web_server.cpp b/esphome/components/web_server/web_server.cpp index 4fdbbbce7d..c6204533d4 100644 --- a/esphome/components/web_server/web_server.cpp +++ b/esphome/components/web_server/web_server.cpp @@ -18,6 +18,8 @@ namespace web_server { static const char *TAG = "web_server"; void write_row(AsyncResponseStream *stream, Nameable *obj, const std::string &klass, const std::string &action) { + if (obj->is_internal()) + return; stream->print("print(klass.c_str()); stream->print("\" id=\""); @@ -135,41 +137,37 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) { stream->print(F("\">

")); stream->print(title.c_str()); stream->print(F("

States

")); + // All content is controlled and created by user - so allowing all origins is fine here. + stream->addHeader("Access-Control-Allow-Origin", "*"); #ifdef USE_SENSOR for (auto *obj : App.get_sensors()) - if (!obj->is_internal()) - write_row(stream, obj, "sensor", ""); + write_row(stream, obj, "sensor", ""); #endif #ifdef USE_SWITCH for (auto *obj : App.get_switches()) - if (!obj->is_internal()) - write_row(stream, obj, "switch", ""); + write_row(stream, obj, "switch", ""); #endif #ifdef USE_BINARY_SENSOR for (auto *obj : App.get_binary_sensors()) - if (!obj->is_internal()) - write_row(stream, obj, "binary_sensor", ""); + write_row(stream, obj, "binary_sensor", ""); #endif #ifdef USE_FAN for (auto *obj : App.get_fans()) - if (!obj->is_internal()) - write_row(stream, obj, "fan", ""); + write_row(stream, obj, "fan", ""); #endif #ifdef USE_LIGHT for (auto *obj : App.get_lights()) - if (!obj->is_internal()) - write_row(stream, obj, "light", ""); + write_row(stream, obj, "light", ""); #endif #ifdef USE_TEXT_SENSOR for (auto *obj : App.get_text_sensors()) - if (!obj->is_internal()) - write_row(stream, obj, "text_sensor", ""); + write_row(stream, obj, "text_sensor", ""); #endif stream->print(F("
NameStateActions

See ESPHome Web API for "