telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

commit 806549bb084e2c18e835cb3ad90664bdb2611e11
parent b03926ef0a8a6f9e5bfa809b1c0dd0ed17849369
Author: Frederic Cambus <fred@statdns.com>
Date:   Sat,  6 Oct 2018 22:38:22 +0200

Add CORS and "Cache-Control" headers for the 'jsonip' and 'location' endpoints

Diffstat:
Msrc/jsonip.c | 4++++
Msrc/location.c | 4++++
2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/jsonip.c b/src/jsonip.c @@ -57,6 +57,10 @@ jsonip(struct http_request *req) answer = json; } + // CORS + http_response_header(req, "Access-Control-Allow-Origin", "*"); + http_response_header(req, "Cache-Control", "no-cache"); + http_response_header(req, "content-type", "application/json; charset=utf-8"); http_response(req, 200, answer, strlen(answer)); diff --git a/src/location.c b/src/location.c @@ -165,6 +165,10 @@ location(struct http_request *req) answer = json; } + // CORS + http_response_header(req, "Access-Control-Allow-Origin", "*"); + http_response_header(req, "Cache-Control", "no-cache"); + http_response_header(req, "content-type", "application/json; charset=utf-8"); http_response(req, 200, answer, strlen(answer));