Fixed 404 error when pressing refresh in webapp
This commit is contained in:
parent
1691274247
commit
cf273c93e7
@ -33,8 +33,6 @@ private:
|
||||
WebApiWsLiveClass _webApiWsLive;
|
||||
|
||||
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
|
||||
|
||||
void onNotFound(AsyncWebServerRequest* request);
|
||||
};
|
||||
|
||||
extern WebApiClass WebApi;
|
||||
@ -30,7 +30,6 @@ void WebApiClass::init()
|
||||
|
||||
_webApiWsLive.init(&_ws);
|
||||
|
||||
_server.onNotFound(std::bind(&WebApiClass::onNotFound, this, _1));
|
||||
_server.begin();
|
||||
}
|
||||
|
||||
@ -51,11 +50,7 @@ void WebApiClass::loop()
|
||||
_ws.cleanupClients();
|
||||
}
|
||||
|
||||
void WebApiClass::onNotFound(AsyncWebServerRequest* request)
|
||||
{
|
||||
// Handle Unknown Request
|
||||
request->send(404, "text/plain", "404 Not Found");
|
||||
}
|
||||
|
||||
|
||||
void WebApiClass::onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len)
|
||||
{
|
||||
|
||||
@ -22,6 +22,12 @@ void WebApiWebappClass::init(AsyncWebServer* server)
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
_server->onNotFound([](AsyncWebServerRequest* request) {
|
||||
AsyncWebServerResponse* response = request->beginResponse_P(200, "text/html", file_index_html_start, file_index_html_end - file_index_html_start);
|
||||
response->addHeader("Content-Encoding", "gzip");
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
_server->on("/index.html", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
AsyncWebServerResponse* response = request->beginResponse_P(200, "text/html", file_index_html_start, file_index_html_end - file_index_html_start);
|
||||
response->addHeader("Content-Encoding", "gzip");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user