           root.printTo(buffer, sizeof(buffer));
 
           AsyncWebServerResponse *response =
-              request->beginResponse(400, PSTR(HTTP_MIMETYPE_JSON), buffer);
-          response->addHeader(PSTR(HTTP_HEADER_SERVER), SERVER_SIGNATURE);
+              request->beginResponse(400, HTTP_MIMETYPE_JSON, buffer);
+          response->addHeader(HTTP_HEADER_SERVER, SERVER_SIGNATURE);
           request->send(response);
 
           return;

      root.printTo(buffer, sizeof(buffer));

      AsyncWebServerResponse *response =
          request->beginResponse(401, PSTR(HTTP_MIMETYPE_JSON), buffer);
      response->addHeader(PSTR(HTTP_HEADER_SERVER), SERVER_SIGNATURE);
      request->send(response);

      return false;

  if (cfg.api) {

    // 'Light' API Endpoint
    server->on(HTTP_APIROUTE_LIGHT, HTTP_GET,
               [](AsyncWebServerRequest *request) {

                 // Check for appropriate HTTP method
                 if (request->method() != HTTP_GET) {
                   AsyncWebServerResponse *response =
                       request->beginResponse(405, HTTP_MIMETYPE_JSON);
                   response->addHeader(HTTP_HEADER_SERVER, SERVER_SIGNATURE);
                   response->addHeader(HTTP_HEADER_ALLOW, "GET, PATCH");
                   request->send(response);

                   return;
                 }

                 if (!authorizeAPI(request)) {
                   return;
                 }

                 // Send response
                 DynamicJsonBuffer jsonBuffer;
                 JsonObject &root = jsonBuffer.createObject();
                 createStateJSON(root);

                 char buffer[root.measureLength() + 1];
                 root.printTo(buffer, sizeof(buffer));

                 AsyncWebServerResponse *response =
                     request->beginResponse(200, HTTP_MIMETYPE_JSON, buffer);
                 response->addHeader(HTTP_HEADER_SERVER, SERVER_SIGNATURE);
                 request->send(response);
               });

    // 'About' API Endpoint
    server->on(HTTP_APIROUTE_ABOUT, HTTP_ANY,
               [](AsyncWebServerRequest *request) {

                 // Only allow HTTP_GET method
                 if (request->method() != HTTP_GET) {
                   AsyncWebServerResponse *response =
                       request->beginResponse(405, HTTP_MIMETYPE_JSON);
                   response->addHeader(HTTP_HEADER_SERVER, SERVER_SIGNATURE);
                   response->addHeader(HTTP_HEADER_ALLOW, "GET");
                   request->send(response);

                   return;
                 }

                 if (!authorizeAPI(request)) {
                   return;
                 }

                 DynamicJsonBuffer jsonBuffer;
                 JsonObject &root = jsonBuffer.createObject();
                 createAboutJSON(root);

                 AsyncResponseStream *response =
                     request->beginResponseStream(HTTP_MIMETYPE_JSON);
                 response->addHeader(HTTP_HEADER_SERVER, SERVER_SIGNATURE);
                 root.printTo(*response);

                 request->send(response);
               });
  }

  // Handle unknown URI
  server->onNotFound([](AsyncWebServerRequest *request) {
    const char *mime_type = HTTP_MIMETYPE_HTML;

    if (cfg.api && request->url().startsWith(HTTP_APIROUTE_ROOT)) {
      mime_type = HTTP_MIMETYPE_JSON;
    }

    AsyncWebServerResponse *response = request->beginResponse(404, mime_type);
    response->addHeader(HTTP_HEADER_SERVER, SERVER_SIGNATURE);
    request->send(response);
  });

