Skip to content

Commit 115c8bd

Browse files
author
Philipp Viereck
committed
adds cloudflare cf object to platform property
this has been done for the pages package but not for workers. see #9978
1 parent fd6eb9b commit 115c8bd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.changeset/cuddly-pigs-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-cloudflare-workers': minor
3+
---
4+
5+
feat: add cloudflare's `request.cf` object to the `event.platform` property
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CacheStorage } from '@cloudflare/workers-types';
1+
import { CacheStorage, IncomingRequestCfProperties } from '@cloudflare/workers-types';
22

33
declare global {
44
namespace App {
@@ -7,6 +7,7 @@ declare global {
77
waitUntil(promise: Promise<any>): void;
88
};
99
caches: CacheStorage;
10+
cf?: IncomingRequestCfProperties;
1011
}
1112
}
1213
}

packages/adapter-cloudflare-workers/files/entry.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export default {
7171
env,
7272
context,
7373
// @ts-expect-error lib.dom is interfering with workers-types
74-
caches
74+
caches,
75+
// @ts-expect-error req is actually a Cloudflare request not a standard request
76+
cf: req.cf
7577
},
7678
getClientAddress() {
7779
return req.headers.get('cf-connecting-ip');

0 commit comments

Comments
 (0)