Espalexa icon indicating copy to clipboard operation
Espalexa copied to clipboard

Can't discover when serving webpage from SPIFFS

Open NimmLor opened this issue 5 years ago • 3 comments

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.

NimmLor avatar Jan 27 '20 10:01 NimmLor

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.

samayg avatar May 04 '20 10:05 samayg

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.

NimmLor avatar May 04 '20 10:05 NimmLor

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.

mrhill avatar Dec 26 '20 00:12 mrhill