Fix: support Unifi widget with Unifi OS v3.2.5+ (#2281)

pull/2283/head
shamoon 1 year ago committed by GitHub
parent 67f5ee8df5
commit 885a4051f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,8 +81,12 @@ export default async function unifiProxyHandler(req, res) {
[status, contentType, data, responseHeaders] = await httpProxy(widget.url); [status, contentType, data, responseHeaders] = await httpProxy(widget.url);
prefix = ""; prefix = "";
if (responseHeaders?.["x-csrf-token"]) { if (responseHeaders?.["x-csrf-token"]) {
// Unifi OS < 3.2.5 passes & requires csrf-token
prefix = udmpPrefix; prefix = udmpPrefix;
csrfToken = responseHeaders["x-csrf-token"]; csrfToken = responseHeaders["x-csrf-token"];
} else if (responseHeaders?.["access-control-expose-headers"]) {
// Unifi OS ≥ 3.2.5 doesnt pass csrf token but still uses different endpoint
prefix = udmpPrefix;
} }
cache.put(`${prefixCacheKey}.${service}`, prefix); cache.put(`${prefixCacheKey}.${service}`, prefix);
} }

Loading…
Cancel
Save