append service name to cache keys
This commit is contained in:
1 parent
702dbd8a82
commit
91d8e56471
6 files changed
+46
-41
No files matched your search
@@ -58,6 +58,7 @@ async function login(widget) {
|
||||
|
||||
export default async function unifiProxyHandler(req, res) {
|
||||
const widget = await getWidget(req);
|
||||
const { service } = req.query;
|
||||
if (!widget) {
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
@@ -68,7 +69,7 @@ export default async function unifiProxyHandler(req, res) {
|
||||
}
|
||||
|
||||
let [status, contentType, data, responseHeaders] = [];
|
||||
let prefix = cache.get(prefixCacheKey);
|
||||
let prefix = cache.get(`${prefixCacheKey}.${service}`);
|
||||
if (prefix === null) {
|
||||
// auto detect if we're talking to a UDM Pro, and cache the result so that we
|
||||
// don't make two requests each time data from Unifi is required
|
||||
@@ -77,7 +78,7 @@ export default async function unifiProxyHandler(req, res) {
|
||||
if (responseHeaders?.["x-csrf-token"]) {
|
||||
prefix = udmpPrefix;
|
||||
}
|
||||
cache.put(prefixCacheKey, prefix);
|
||||
cache.put(`${prefixCacheKey}.${service}`, prefix);
|
||||
}
|
||||
|
||||
widget.prefix = prefix;
|
||||
|
||||
Reference in new issue
Block a user