Add data transfer middleware
This commit is contained in:
parent
6e57ce6daa
commit
2668fb4e2a
17
functions/api/data-transfers/_middleware.ts
Normal file
17
functions/api/data-transfers/_middleware.ts
Normal file
@ -0,0 +1,17 @@
|
||||
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) => {
|
||||
const [name, value] = cookie.split("=");
|
||||
|
||||
return { name, value };
|
||||
});
|
||||
|
||||
const transferId = cookieList.find((cookie) => cookie.name === "__dtid");
|
||||
|
||||
if (transferId) context.data.data_transfer_id = transferId;
|
||||
|
||||
return await context.next();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user