Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
539 stars 135 forks source link

Can't discover when serving webpage from SPIFFS #100

Open NimmLor opened 4 years ago

NimmLor commented 4 years ago

Hi, I've been experimenting with your library in combination with jasoncoon's fastled-webserver that stores webpages inside the SPIFFS of the esp8266.

I've adapted the code to use the webserver as shown in the example and it only works when the line that loads the webpage from the SPIFFS is removed. webServer.serveStatic("/", SPIFFS, "/", "max-age=86400"); It took me some time to notice that this was causing the discovery issues.

But now I don't know how to fix this issue, because it is essential to load the page from the spiffs.

samayg commented 4 years ago

For anyone else having the same issue, I seem to have worked around this issue by commenting out the webServer.serveStatic("/", SPIFFS, "/", "max-age=86400"); line, discovering and adding the devices in the alexa app, then adding back that line and reprogramming the ESP. Both the webpage and Alexa functions seem to be working as of now.

NimmLor commented 4 years ago

A workaround would be to implement a function that can be started from the regular UI that stops the webserver and starts a second webserver that only creates the necessary espalexa endpoints without serving anything from the spiffs. However the esp requires a reboot after alexa is paired. This was the final solution I've used in my project.

mrhill commented 3 years ago

This is not an issue with Espalexa -- the problem is in ESP8266WebServer's StaticRequestHandler. The implementation of its canHandle() method returns true for all URLs, regardless of whether the file actually exists on SPIFFS or not. That makes it a catch-all, and the Espalexa onNotFound() 404 handler which implements the /api endpoint will never get called. You could probably try to file a ticket against that project.