httpNotFound remove trailing slash

This commit is contained in:
Patrick Haßel 2025-02-19 15:59:16 +01:00
parent 8c8c35fb5f
commit 97f711a22d

View File

@ -6,7 +6,10 @@
AsyncWebServer server(80);
void httpNotFound(AsyncWebServerRequest* request) {
if (request->method() == HTTP_OPTIONS) {
const String path = request->url();
if (path.endsWith("/") && path.length() > 1) {
request->redirect(path.substring(0, path.length() - 1));
} else if (request->method() == HTTP_OPTIONS) {
request->send(200);
} else {
request->send(404, "text/plain", "not found");