diff --git a/services/natQueue.js b/services/natQueue.js index 89932ef..6995863 100644 --- a/services/natQueue.js +++ b/services/natQueue.js @@ -22,10 +22,12 @@ async function opnsenseRequest(method, path, body = null) { method, headers: { 'Authorization': `Basic ${auth}`, - 'Content-Type': 'application/json', }, }; - if (body) opts.body = JSON.stringify(body); + if (body) { + opts.headers['Content-Type'] = 'application/json'; + opts.body = JSON.stringify(body); + } const res = await fetch(`${process.env.OPNSENSE_HOST}${path}`, opts); const text = await res.text(); try { @@ -80,9 +82,7 @@ export function enqueueNatRemove(ip, port, proto = 'tcp/udp') { info(rule.descr); if (rule.descr === `pelican-${ip}-${port}`) { info(JSON.stringify(rule)); - let res = await opnsenseRequest('POST', `/api/firewall/d_nat/delRule`, { - uuid: rule.uuid, - }); + let res = await opnsenseRequest('POST', `/api/firewall/d_nat/delRule/${rule.uuid}`); info(JSON.stringify(res)); success(`deleted rule udp+tcp at ${ip}:${port}`); }