mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
append service name to cache keys
This commit is contained in:
parent
702dbd8a82
commit
91d8e56471
6 changed files with 46 additions and 41 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue