cotestatnt / esp-fs-webserver

ESP32/ESP8266 webserver, WiFi manager and web editor Arduino library
MIT License
120 stars 29 forks source link

Disable Captive Portal?? #35

Closed IAmOrion closed 11 months ago

IAmOrion commented 11 months ago

How on earth do I disable the captive portal with this library? I'm using it in AP mode only, but it still presents the captive portal popup when I connect to it (which defaults to /setup) - but I want to disable this, I don't need it at all.

many thanks in advance

cotestatnt commented 11 months ago

Hi @IAmOrion, unfortunately I have not provided an explicit instruction to deactivate the captive portal.

You need to comment out these lines in the file esp-fs-webserver.cpp

   // Captive Portal redirect
    webserver->on("/redirect", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    // Windows
    webserver->on("/connecttest.txt", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    // Apple
    webserver->on("/hotspot-detect.html", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    // Android
    webserver->on("/generate_204", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    webserver->on("/gen_204", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));

In any case, if you need to create some kind of HMI, I recommend you take a look at this new version of the library based on the ESPAsyncWebServer component which, compared to the one integrated into the core, has greater reactivity and better page loadtime.

async-esp-fs-webserver https://github.com/cotestatnt/async-esp-fs-webserver

IAmOrion commented 11 months ago

Hi @IAmOrion, unfortunately I have not provided an explicit instruction to deactivate the captive portal.

You need to comment out these lines in the file esp-fs-webserver.cpp

   // Captive Portal redirect
    webserver->on("/redirect", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    // Windows
    webserver->on("/connecttest.txt", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    // Apple
    webserver->on("/hotspot-detect.html", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    // Android
    webserver->on("/generate_204", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));
    webserver->on("/gen_204", HTTP_GET, std::bind(&FSWebServer::captivePortal, this));

In any case, if you need to create some kind of HMI, I recommend you take a look at this new version of the library based on the ESPAsyncWebServer component which, compared to the one integrated into the core, has greater reactivity and better page loadtime.

async-esp-fs-webserver https://github.com/cotestatnt/async-esp-fs-webserver

Perfect thanks. I figured I could comment that stuff out but was hoping I was just missing an easy method/function to disable but you answered that also so that's great, thanks :)

I shall take look at the newer async library now too, many thanks