I am configuring à nginx location but I need to run a script that update requestBody before redirection :
This my conf but when i deploy it still redirect without update requestBody or return error
Parent nginx.conf:
// .....
js_import checkScript from /etc/nginx/js/scripts/checkScript.js;
// ....
In checkScript.js :
export default {
rights
}
function rights(r) {
const body = JSON.parse(r.requestBody);
if (body.isAdmin) {
body.rights = ['ADMIN'];
r.requestBody = JSON.stringify(body);
} else {
r.return(403, 'Not admin');
}
}
products.http-service.conf :
location /api/data/products/new {
set $gateway_role "dev.yumStore";
set $gateway_realm "yumStore";
auth_request /_tokenExchange;
# check rights and update body
js_content checkScript.rights;
proxy_set_header "Authorization" $gateway_auth_header;
# redirection
proxy_pass $OUTGATEWAY/api/data/products/new;
}
Thanks for help!!