Software /
code /
prosody
Changeset
11396:f6bb3b193277
mod_http: Allow setting the CORS credentials flag via :provides API
E.g.
module:provides("http", {
cors = {
credentials = true;
};
route = { ... };
});
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 30 Dec 2019 09:49:28 +0100 |
parents | 11395:d336b28b4002 |
children | 11397:27a22a1f141c |
files | plugins/mod_http.lua |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_http.lua Sun Feb 21 07:59:17 2021 +0100 +++ b/plugins/mod_http.lua Mon Dec 30 09:49:28 2019 +0100 @@ -129,10 +129,11 @@ local app_handlers = apps[app_name]; local app_methods = opt_methods; + local app_credentials = opt_credentials; local function cors_handler(event_data) local request, response = event_data.request, event_data.response; - apply_cors_headers(response, app_methods, opt_headers, opt_max_age, opt_credentials, request.headers.origin); + apply_cors_headers(response, app_methods, opt_headers, opt_max_age, app_credentials, request.headers.origin); end local function options_handler(event_data) @@ -140,6 +141,13 @@ return ""; end + if event.item.cors then + local cors = event.item.cors; + if cors.credentials ~= nil then + app_credentials = cors.credentials; + end + end + local streaming = event.item.streaming_uploads; for key, handler in pairs(event.item.route or {}) do