Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 retry #185

Merged
merged 4 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions data_source/kegcop_pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ const UA = navigator.userAgent;
// Use last known theme:
var theme = localStorage.getItem('theme');
if (theme) {
console.info("A 404 for the '_aux' file here is normal.");
document.getElementById('theme').href = theme.url || "https://cdn.jsdelivr.net/npm/bootswatch@5/dist/cerulean/bootstrap.min.css";
if (is404) {
document.getElementById('theme_aux').href = "/" + theme.css || "/cerulean_aux.css";
} else {
document.getElementById('theme_aux').href = theme.css || "cerulean_aux.css";
}
document.getElementById('theme_aux').href = theme.css || "cerulean_aux.css";
document.querySelector('meta[name="theme-color"]').setAttribute("content", theme.color || "#ffffff");
}

Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ lib_ignore = ;ESPAsynTCP
lib_deps =
paulstoffregen/OneWire @ ~2.3.7
lbussy/LCBUrl @ ~1.1.9
bblanchon/ArduinoJson @ ~6.19.4
bblanchon/ArduinoJson @ ~6.21.2
https://github.com/lbussy/DS18B20_RT @ ~0.1.4
https://github.com/lbussy/Arduino-Log @ ~1.0.3
https://github.com/lbussy/AsyncWiFiManager.git
Expand Down
4 changes: 3 additions & 1 deletion src/flowconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bool loadFlowConfig()
}
else if (!deserializeFlowConfig(file))
{
// TODO: This was where one issue was reported
Log.error(F("Flow Load: Failed to load flowmeter configuration from filesystem, default values have been used." CR));
flowLoadError = true; // DEBUG
debugFlowmeterLog(true); // DEBUG
Expand Down Expand Up @@ -101,7 +102,7 @@ bool saveFlowConfig()
saveOK = true;
}
file.close();

// TODO: Make copy
return saveOK;
}

Expand Down Expand Up @@ -366,4 +367,5 @@ void debugFlowmeterLog(int numTap, bool fileExist) // DEBUG
Log.error(F("%s Unable to write log file." CR), debugPrefix);
}
file.close();
// TODO: Restore copy and load
}
20 changes: 16 additions & 4 deletions src/webpagehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,22 @@ void startWebServer()
}
else
{
Log.verbose(F("Processing 404 for %s." CR), request->url().c_str());
AsyncWebServerResponse* response = request->beginResponse(FILESYSTEM, "/404.htm", "text/html");
response->setCode(404);
request->send(response);
bool do404 = true;
// This is to catch anything that gets here with a filename in other than root
if (request->url().indexOf(".") >= 0 && request->url().indexOf("/") >= 0)
{
String url = request->url().substring(request->url().lastIndexOf("/"), request->url().length());
Log.notice(F("404 rewrite: Rewriting %s to %s" CR), request->url().c_str(), url.c_str());
request->send(FILESYSTEM, url, "text/html");
do404 = false;
}
if (do404)
{
Log.warning(F("Processing 404 for %s." CR), request->url().c_str());
AsyncWebServerResponse* response = request->beginResponse(FILESYSTEM, "/404.htm", "text/html");
response->setCode(404);
request->send(response);
}
} });

DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
Expand Down