feat: implement captive portal redirects for auto-loading the management page on hotspot mode (#2550)
This commit is contained in:
@@ -353,6 +353,15 @@ void CrossPointWebServer::handleJszip() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CrossPointWebServer::handleNotFound() const {
|
void CrossPointWebServer::handleNotFound() const {
|
||||||
|
// in AP mode, redirect unmatched browser/captive-portal requests to "/" so the OS auto-opens the browser
|
||||||
|
// API requests (/api/*) still return 404 so XHR errors surface correctly
|
||||||
|
// see https://en.wikipedia.org/wiki/Captive_portal#Detection
|
||||||
|
if (apMode && !server->uri().startsWith("/api/")) {
|
||||||
|
server->sendHeader("Location", "/", true);
|
||||||
|
server->send(302, "text/plain", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String message = "404 Not Found\n\n";
|
String message = "404 Not Found\n\n";
|
||||||
message += "URI: " + server->uri() + "\n";
|
message += "URI: " + server->uri() + "\n";
|
||||||
server->send(404, "text/plain", message);
|
server->send(404, "text/plain", message);
|
||||||
|
|||||||
Reference in New Issue
Block a user