Skip to content

Commit b5d96cb

Browse files
Spiouneteemingc
andauthored
adds cloudflare cf object to platform property (#9978)
* adds cloudflare cf object to platform property * Update afraid-bikes-count.md --------- Co-authored-by: Spioune <> Co-authored-by: Tee Ming <[email protected]>
1 parent 195e9ac commit b5d96cb

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.changeset/afraid-bikes-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-cloudflare': 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 { Cache, CacheStorage } from '@cloudflare/workers-types';
1+
import { Cache, 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 & { default: Cache };
10+
cf?: IncomingRequestCfProperties;
1011
}
1112
}
1213
}

packages/adapter-cloudflare/src/worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const worker = {
4646
// dynamically-generated pages
4747
res = await server.respond(req, {
4848
// @ts-ignore
49-
platform: { env, context, caches },
49+
platform: { env, context, caches, cf: req.cf },
5050
getClientAddress() {
5151
return req.headers.get('cf-connecting-ip');
5252
}

0 commit comments

Comments
 (0)