From 1ca9cdc52f3b63c8bf5e4550bbb922608beb437f Mon Sep 17 00:00:00 2001 From: Darkelarious Date: Sun, 7 Aug 2022 17:58:59 +0200 Subject: fixes in Json API --- lib/MasterWebInterface/Handler/Json/JsonServerInfo.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/MasterWebInterface/Handler/Json/JsonServerInfo.pm') diff --git a/lib/MasterWebInterface/Handler/Json/JsonServerInfo.pm b/lib/MasterWebInterface/Handler/Json/JsonServerInfo.pm index 5669003..2ff6194 100755 --- a/lib/MasterWebInterface/Handler/Json/JsonServerInfo.pm +++ b/lib/MasterWebInterface/Handler/Json/JsonServerInfo.pm @@ -22,11 +22,14 @@ sub json_serverinfo hostport => $port, limit => 1, )->[0] if ($ip && $port); - + + # allow all outside sources to access the json api + $self->resHeader("Access-Control-Allow-Origin", "*"); + # return error state on invalid IP/port unless ($info) { - $self->resHeader("Content-Type", "application/json; charset=UTF-8"); + # response as json data $self->resJSON({ error => 1, in => "not_in_db", @@ -70,8 +73,7 @@ sub json_serverinfo $info->{mapurl} = "/map/default/333networks.jpg"; } - # return json data as the response - $self->resHeader("Content-Type", "application/json; charset=UTF-8"); + # response as json data $self->resJSON($info); } -- cgit v1.2.3