diff --git a/src/handlers/admin/admin_handler_admins.erl b/src/handlers/admin/admin_handler_admins.erl index 6e5ee54..f70326b 100644 --- a/src/handlers/admin/admin_handler_admins.erl +++ b/src/handlers/admin/admin_handler_admins.erl @@ -102,9 +102,14 @@ datetime_to_iso8601({{Y,M,D},{H,Min,S}}) -> datetime_to_iso8601(_) -> null. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - Req2 = cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), - {ok, Req2, []}. + cowboy_req:reply(Status, Headers, Body, Req), + {ok, Body, []}. send_error(Req, Code, Message) -> Body = jsx:encode(#{error => Message}), diff --git a/src/handlers/admin/admin_handler_banned_words.erl b/src/handlers/admin/admin_handler_banned_words.erl index 9ab8c34..0124067 100644 --- a/src/handlers/admin/admin_handler_banned_words.erl +++ b/src/handlers/admin/admin_handler_banned_words.erl @@ -117,8 +117,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_reports.erl b/src/handlers/admin/admin_handler_reports.erl index ab5a3cb..e79d6ec 100644 --- a/src/handlers/admin/admin_handler_reports.erl +++ b/src/handlers/admin/admin_handler_reports.erl @@ -94,8 +94,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_reviews.erl b/src/handlers/admin/admin_handler_reviews.erl index ce78726..e104f24 100644 --- a/src/handlers/admin/admin_handler_reviews.erl +++ b/src/handlers/admin/admin_handler_reviews.erl @@ -78,8 +78,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_subscriptions.erl b/src/handlers/admin/admin_handler_subscriptions.erl index ddc9298..dde61b9 100644 --- a/src/handlers/admin/admin_handler_subscriptions.erl +++ b/src/handlers/admin/admin_handler_subscriptions.erl @@ -141,8 +141,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_ticket_stats.erl b/src/handlers/admin/admin_handler_ticket_stats.erl index c12d384..2871045 100644 --- a/src/handlers/admin/admin_handler_ticket_stats.erl +++ b/src/handlers/admin/admin_handler_ticket_stats.erl @@ -31,8 +31,13 @@ auth_admin(Req) -> end. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_tickets.erl b/src/handlers/admin/admin_handler_tickets.erl index e073dd8..aea79fa 100644 --- a/src/handlers/admin/admin_handler_tickets.erl +++ b/src/handlers/admin/admin_handler_tickets.erl @@ -141,8 +141,13 @@ datetime_to_iso8601({{Year, Month, Day}, {Hour, Minute, Second}}) -> datetime_to_iso8601(undefined) -> undefined. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) -> diff --git a/src/handlers/admin/admin_handler_users.erl b/src/handlers/admin/admin_handler_users.erl index 554888f..d23a7ab 100644 --- a/src/handlers/admin/admin_handler_users.erl +++ b/src/handlers/admin/admin_handler_users.erl @@ -46,8 +46,13 @@ datetime_to_iso8601({{Y,M,D},{H,Min,S}}) -> datetime_to_iso8601(_) -> null. send_json(Req, Status, Data) -> + Headers = #{ + <<"content-type">> => <<"application/json">>, + <<"access-control-allow-origin">> => <<"*">>, + <<"access-control-expose-headers">> => <<"Content-Range">> + }, Body = jsx:encode(Data), - cowboy_req:reply(Status, #{<<"content-type">> => <<"application/json">>}, Body, Req), + cowboy_req:reply(Status, Headers, Body, Req), {ok, Body, []}. send_error(Req, Status, Message) ->