X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgi.c;h=c67aed4b1468f39af03baa7872fb6e19aa40dd97;hp=226017602f61c7531c62eb5e7967f83fd0b0a7b8;hb=9fd58c0d3a56323ce94837f217e6609e9c7b2402;hpb=96bf13e8606919027cc3dc3597627396b9e55a0a diff --git a/cgi.c b/cgi.c index 22601760..c67aed4b 100644 --- a/cgi.c +++ b/cgi.c @@ -1585,6 +1585,18 @@ struct http_response *finish_http_response(struct client_state *csp, struct http return rsp; } + /* + * Add "Cross-origin resource sharing" (CORS) headers if enabled + */ + if (NULL != csp->config->cors_allowed_origin) + { + enlist_unique_header(rsp->headers, "Access-Control-Allow-Origin", + strdup_or_die(csp->config->cors_allowed_origin)); + enlist_unique_header(rsp->headers, "Access-Control-Allow-Methods", "GET,POST"); + enlist_unique_header(rsp->headers, "Access-Control-Allow-Headers", "X-Requested-With"); + enlist_unique_header(rsp->headers, "Access-Control-Max-Age", "86400"); + } + /* * Fill in the HTTP Status, using HTTP/1.1 * unless the client asked for HTTP/1.0.