Skip to content

Commit 3c7cd9d

Browse files
committed
fix: do not throw if request.cf is not set
1 parent 4a500ee commit 3c7cd9d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/open-next/src/overrides/wrappers/cloudflare.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ const handler: WrapperHandler<
4141
// Retrieve geo information from the cloudflare request
4242
// See https://developers.cloudflare.com/workers/runtime-apis/request
4343
// Note: This code could be moved to a cloudflare specific converter when one is created.
44-
const cfProperties = (request as any).cf as Record<string, string | null>;
44+
const cfProperties = (request as any).cf as
45+
| Record<string, string | null>
46+
| undefined;
4547
for (const [propName, headerName] of Object.entries(
4648
cfPropNameToHeaderName,
4749
)) {
48-
const propValue = cfProperties[propName];
49-
if (propValue !== null) {
50+
const propValue = cfProperties?.[propName];
51+
if (propValue != null) {
5052
internalEvent.headers[headerName] = propValue;
5153
}
5254
}

0 commit comments

Comments
 (0)