diff --git a/src/conffile.c b/src/conffile.c index c8571f3d..0c26fc99 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -55,6 +55,7 @@ static cfg_opt_t sec_general[] = CFG_BOOL("ipv6", cfg_true, CFGF_NONE), CFG_STR("cache_path", STATEDIR "/cache/" PACKAGE "/cache.db", CFGF_NONE), CFG_INT("cache_daap_threshold", 1000, CFGF_NONE), + CFG_STR("allow_origin", NULL, CFGF_NONE), CFG_END() }; diff --git a/src/httpd.c b/src/httpd.c index be68364b..bd057f2d 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -678,6 +678,7 @@ httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struc int flush; int zret; int ret; + char *origin; if (!req) return; @@ -774,6 +775,10 @@ httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struc headers = evhttp_request_get_output_headers(req); + origin = cfg_getstr(cfg_getsec(cfg, "general"), "allow_origin"); + if (origin && strlen(origin)) + evhttp_add_header(headers, "Access-Control-Allow-Origin", origin); + evhttp_add_header(headers, "Content-Encoding", "gzip"); evhttp_send_reply(req, code, reason, gzbuf);