Skip to content

Commit

Permalink
fix(cloudflare-pages): cloudflare context at top level for back compat (
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori authored Feb 21, 2024
1 parent 9d97f21 commit dc111d9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .changeset/great-jokes-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@remix-run/cloudflare-pages": patch
---

Fix breaking change for `@remix-run/cloudflare-pages`

Restore Cloudflare event context fields in `getLoadContext` argument for backwards compatibility.


20 changes: 20 additions & 0 deletions packages/remix-cloudflare-pages/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ export type GetLoadContextFunction<
Params extends string = any,
Data extends Record<string, unknown> = Record<string, unknown>
> = (args: {
/** @deprecated use `context.cloudflare.env` instead */
env: EventContext<Env, Params, Data>["env"];
/** @deprecated use `context.cloudflare.functionPath` instead */
functionPath: EventContext<Env, Params, Data>["functionPath"];
/** @deprecated use `context.cloudflare.waitUntil` instead */
waitUntil: EventContext<Env, Params, Data>["waitUntil"];
/** @deprecated use `context.cloudflare.passThroughOnException` instead */
passThroughOnException: EventContext<
Env,
Params,
Data
>["passThroughOnException"];
/** @deprecated use `context.cloudflare.next` instead */
next: EventContext<Env, Params, Data>["next"];
/** @deprecated use `context.cloudflare.params` instead */
params: EventContext<Env, Params, Data>["params"];
/** @deprecated use `context.cloudflare.data` instead */
data: EventContext<Env, Params, Data>["data"];

request: Request;
context: {
cloudflare: EventContext<Env, Params, Data> & {
Expand Down Expand Up @@ -54,6 +73,7 @@ export function createRequestHandler<Env = any>({

return async (cloudflare) => {
let loadContext = await getLoadContext({
...cloudflare, // Backcompat, remove in v3
request: cloudflare.request,
context: {
cloudflare: {
Expand Down

0 comments on commit dc111d9

Please sign in to comment.