20 lines
526 B
TypeScript
20 lines
526 B
TypeScript
export async function onRequest(context: RequestContext) {
|
|
const cookies = context.request.headers.get("cookie");
|
|
|
|
if (!cookies) return await context.next();
|
|
|
|
const cookieList = cookies.split("; ").map((cookie: string) => {
|
|
const [name, value] = cookie.split("=");
|
|
|
|
return { name, value };
|
|
});
|
|
|
|
const transferId = cookieList.find(
|
|
(cookie: { name: string; value: string }) => cookie.name === "__dtid",
|
|
);
|
|
|
|
if (transferId) context.data.data_transfer_id = transferId;
|
|
|
|
return await context.next();
|
|
}
|