Skip to content

best way to save what you love

api/core: mark request as session when bearer token is used

wukkoc5acb45557fa
diff --git a/api/src/core/api.js b/api/src/core/api.js
index 3231767f..f5e09940 100644
--- a/api/src/core/api.js
+++ b/api/src/core/api.js
@@ -181,6 +181,7 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
}
req.rateLimitKey = hashHmac(token, 'rate');
+ req.isSession = true;
} catch {
return fail(res, "error.api.generic");
}
@@ -245,6 +246,7 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
if (!parsed) {
return fail(res, "error.api.link.invalid");
}
+
if ("error" in parsed) {
let context;
if (parsed?.context) {
@@ -258,13 +260,14 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
host: parsed.host,
patternMatch: parsed.patternMatch,
params: normalizedRequest,
+ isSession: req.isSession ?? false,
});
res.status(result.status).json(result.body);
} catch {
fail(res, "error.api.generic");
}
- })
+ });
app.use('/tunnel', cors({
methods: ['GET'],
diff --git a/api/src/processing/match.js b/api/src/processing/match.js
index 532c8f3d..d51a0661 100644
--- a/api/src/processing/match.js
+++ b/api/src/processing/match.js
@@ -32,7 +32,7 @@ import xiaohongshu from "./services/xiaohongshu.js";
let freebind;
-export default async function({ host, patternMatch, params }) {
+export default async function({ host, patternMatch, params, isSession }) {
const { url } = params;
assert(url instanceof URL);
let dispatcher, requestIP;