mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-09 10:14:26 +02:00
api/core: mark request as session when bearer token is used
and pass it to match() for future consumption
This commit is contained in:
parent
d0539118ce
commit
c5acb45557
@ -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'],
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user