Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add data transfer middleware
  • Loading branch information
regalijan committed Nov 21, 2023
1 parent 6e57ce6 commit 2668fb4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions functions/api/data-transfers/_middleware.ts
@@ -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();
}

0 comments on commit 2668fb4

Please sign in to comment.