Skip to content

Commit

Permalink
fix: do not clone the request in case it is currently being read
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernxst committed Jun 5, 2024
1 parent b35cd9a commit 770bb4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-spies-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@galaxiajs/cloudflare-kit": patch
---

(breaking): do not clone the request in case it is currently being read
5 changes: 2 additions & 3 deletions packages/cloudflare/src/modules/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { useHandlerContext } from "./context/context";

/**
* @template {Request | CfRequest} T Optional cast if you need the standard `Request` type
* @returns {import("@cloudflare/workers-types").Request} A clone of
* the current {@linkcode Request}
* @returns {import("@cloudflare/workers-types").Request} The current {@linkcode Request}
*/
export function request<T extends Request | CfRequest = CfRequest>(): T {
const { request } = useHandlerContext();
return request.clone() as unknown as T;
return request as unknown as T;
}

/**
Expand Down

0 comments on commit 770bb4a

Please sign in to comment.