s00500 / ESPUI

A simple web user interface library for ESP32 and ESP8266

Home Page:https://valencia.lbsfilm.at/midterm-presentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make redirection of all 'not found' URLs a configuration option

ncmreynolds opened this issue · comments

Similar to discussion in issue #25 "Captive portal" I am trying to use ESPUI in a situation where I would like it to be hard for a user to fail to hit the page.

My suggestion is to make a configuration method to change the handling of 404 errors by ESPUI so OPTIONALLY they redirect to /

I have done this myself by replacing line 1135 of ESPUI.cpp...

server->onNotFound([](AsyncWebServerRequest* request) { request->send(404); });

with...

server->onNotFound([](AsyncWebServerRequest* request) { request->redirect("/"); });

but this is obviously a one-off hack, ideally it should be optionally set using a new method.

If you like this idea I might look at doing a pull request for it myself. It seems to help with the ESPUI interface being brought up automatically in captive portal type situations.

Great, yes PRs are welcome