diff --git a/lib/remote/httpconnection.cpp b/lib/remote/httpconnection.cpp
index 654988ca4..6aee8a19c 100644
--- a/lib/remote/httpconnection.cpp
+++ b/lib/remote/httpconnection.cpp
@@ -149,6 +149,7 @@ void HttpConnection::ProcessMessageAsync(HttpRequest& request)
if (!user) {
response.SetStatus(401, "Unauthorized");
+ response.AddHeader("Content-Type", "text/html");
response.AddHeader("WWW-Authenticate", "Basic realm=\"Icinga 2\"");
String msg = "
Unauthorized
";
response.WriteBody(msg.CStr(), msg.GetLength());
diff --git a/lib/remote/httphandler.cpp b/lib/remote/httphandler.cpp
index fde43c2b5..d785952ac 100644
--- a/lib/remote/httphandler.cpp
+++ b/lib/remote/httphandler.cpp
@@ -88,6 +88,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request,
if (!handler || (!exact_match && !handler->CanAlsoHandleUrl(request.RequestUrl))) {
response.SetStatus(404, "Not found");
+ response.AddHeader("Content-Type", "text/html");
String msg = "Not found
";
response.WriteBody(msg.CStr(), msg.GetLength());
response.Finish();